Saya sedang membangun dua solusi dalam konfigurasi Rilis. Namun, solusi kedua membangun kembali beberapa proyek di Debug!
Saya dapat mengurangi test case seminimal mungkin. Ini berisi 4 file - 2 file sln dan 2 file csproj.
Di sini mereka:
DataSvc.sln
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.2048
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{04455D86-A7A4-41E5-B3ED-B0BC65EAFDFD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Compensation.Data", "Compensation.Data\Compensation.Data.csproj", "{04DF77A2-912B-40B7-B398-E9558519CAEE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{04455D86-A7A4-41E5-B3ED-B0BC65EAFDFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{04455D86-A7A4-41E5-B3ED-B0BC65EAFDFD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{04455D86-A7A4-41E5-B3ED-B0BC65EAFDFD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{04455D86-A7A4-41E5-B3ED-B0BC65EAFDFD}.Release|Any CPU.Build.0 = Release|Any CPU
{04DF77A2-912B-40B7-B398-E9558519CAEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{04DF77A2-912B-40B7-B398-E9558519CAEE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{04DF77A2-912B-40B7-B398-E9558519CAEE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{04DF77A2-912B-40B7-B398-E9558519CAEE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9ED7ECEC-075D-486A-B3F6-9E80EED49AEF}
EndGlobalSection
EndGlobal
Utama.sln
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.2026
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Compensation.Data", "Compensation.Data\Compensation.Data.csproj", "{04DF77A2-912B-40B7-B398-E9558519CAEE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{04DF77A2-912B-40B7-B398-E9558519CAEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{04DF77A2-912B-40B7-B398-E9558519CAEE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{04DF77A2-912B-40B7-B398-E9558519CAEE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{04DF77A2-912B-40B7-B398-E9558519CAEE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6FBE2C7C-DCEA-4F88-BF8E-FF4927DEFBE5}
EndGlobalSection
EndGlobal
Umum\Umum.csproj
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{04455D86-A7A4-41E5-B3ED-B0BC65EAFDFD}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Xyz.Common</RootNamespace>
<AssemblyName>Xyz.Common</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<OutputPath>Bin\$(Configuration)</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Kompensasi.Data.csproj
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{04DF77A2-912B-40B7-B398-E9558519CAEE}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Compensation.Data</RootNamespace>
<AssemblyName>Compensation.Data</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<OutputPath>Bin\$(Configuration)</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj">
<Project>{04455d86-a7a4-41e5-b3ed-b0bc65eafdfd}</Project>
<Name>Common</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Hal yang perlu diperhatikan:
- Proyek
Compensation.Data
dimuat di DataSvc.sln dan Main.sln - Proyek
Compensation.Data
mereferensikan proyekCommon
sebagai proyek, bukan DLL, meskipun tidak ditemukan diMain.sln
Masalahnya - saat mengkompilasi dua solusi di Rilis, Main.sln membangun Common
di Debug!
Mohon diperhatikan:
C:\work\MSBuildBug [master]> git clean -qdfX
C:\work\MSBuildBug [master]> Test-Path .\Common\bin\Debug
False
C:\work\MSBuildBug [master]> msbuild .\DataSvc.sln /v:m /nowarn:CS2008 /nologo /p:Configuration=Release
Common -> C:\work\MSBuildBug\Common\Bin\Release\Xyz.Common.dll
Compensation.Data -> C:\work\MSBuildBug\Compensation.Data\Bin\Release\Compensation.Data.dll
C:\work\MSBuildBug [master]> Test-Path .\Common\bin\Debug
False
C:\work\MSBuildBug [master]> msbuild .\Main.sln /v:m /nowarn:CS2008 /nologo /p:Configuration=Release
Common -> C:\work\MSBuildBug\Common\Bin\Debug\Xyz.Common.dll
Compensation.Data -> C:\work\MSBuildBug\Compensation.Data\Bin\Release\Compensation.Data.dll
C:\work\MSBuildBug [master]> Test-Path .\Common\bin\Debug
True
C:\work\MSBuildBug [master]> dir .\Common\bin\Debug
Directory: C:\work\MSBuildBug\Common\bin\Debug
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2/18/2020 1:24 AM 3584 Xyz.Common.dll
-a---- 2/18/2020 1:24 AM 7680 Xyz.Common.pdb
C:\work\MSBuildBug [master]>
Ini berfungsi seperti ini di VS 2017 dan VS 2019.
Apa yang kulewatkan di sini? Mengapa itu dikompilasi di Debug?
Main.sln
hanya memilikiCompensation.Data
proyek, tetapi memilikiCommon
referensi proyek. Sudahkah Anda mencoba menambahkanCommon
keMain.sln
juga? - person Pavel Anikhouski   schedule 18.02.2020