I've a very similar problem than described in the following question Visual Studio C# projects force a rebuild when switching from debug to release and vice-versa.
I've C# two projects and one has project reference to the other. If I build (F6) in Debug and than I build (F6) in Release. If I now switch back to Debug and build (F6) it should be up to date.
That's is actually the case. So I can see that in the bin/Debug folder the file date and the assembly version are not changing.
But if I switch on the XML documentation file for the project which has project reference to the other under Project Properties / Build / Output for both configurations (Debug and Release) then the projects gets rebuild every time I switch from Debug to Release or vice-versa.
To recreate the issue:
- Click
File
/New Project...
- Create a new
Visual C#
-->Console Application
. Leave the generated code as-is. - Right-click on the new solution in the solution explorer and select
Add
->New Project...
- Choose
Visual C#
-->Class Library
. Leave the generated code as-is. - Right-click on the
ConsoleApplication1
in the solution explorer and selectAdd Reference...
- Check the box next to
ClassLibrary1
inSolution
->Projects
and hitOK
. - Switch on the
XML documentation file
for theConsoleApplication1
under ProjectProperties
/Build
/Output
for both configurations (Debug
andRelease
) - Build the project in
Debug
configuration. It builds, as expected. - Switch to
Release
configuration and build again. It builds, as expected. - Switch back to
Debug
and build again. It builds, and it shouldn't. It's already been built, right? All we did was change the target configuration selection.
I'm getting the following build output:
1>------ Build started: Project: ConsoleApplication1, Configuration: Debug Any CPU ------
1>Build started 07.09.2018 13:46:43.
1>GenerateTargetFrameworkMonikerAttribute:
1>Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
1>CoreCompile:
1> C:\Program Files (x86)\MSBuild\12.0\bin\Csc.exe /noconfig /nowarn:1701,1702,2008 /nostdlib+ /platform:anycpu32bitpreferred /errorreport:prompt /warn:4 /doc:bin\Debug\ConsoleApplication1.XML /define:DEBUG;TRACE /errorendlocation /preferreduilang:en-US /highentropyva+ /reference:H:\CSharp\TestRebuild\ClassLibrary1\bin\Debug\ClassLibrary1.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Microsoft.CSharp.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.DataSetExtensions.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.Linq.dll" /debug+ /debug:full /filealign:512 /optimize- /out:obj\Debug\ConsoleApplication1.exe /subsystemversion:6.00 /target:exe /utf8output Program.cs Properties\AssemblyInfo.cs "C:\Users\WO\AppData\Local\Temp\.NETFramework,Version=v4.5.AssemblyAttributes.cs" obj\Debug\\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs obj\Debug\\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs obj\Debug\\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
1>_CopyAppConfigFile:
1>Skipping target "_CopyAppConfigFile" because all output files are up-to-date with respect to the input files.
1>CopyFilesToOutputDirectory:
1> Copying file from "obj\Debug\ConsoleApplication1.exe" to "bin\Debug\ConsoleApplication1.exe".
1> ConsoleApplication1 -> H:\CSharp\TestRebuild\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe
1>
1>Build succeeded.
1>
1>Time Elapsed 00:00:00.41
========== Build: 1 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
If XML documentation file
is switched off I'm getting the following build output (it skips the CoreCompile as it should):
1>------ Build started: Project: ConsoleApplication1, Configuration: Debug Any CPU ------
1>Build started 07.09.2018 13:50:17.
1>GenerateTargetFrameworkMonikerAttribute:
1>Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
1>CoreCompile:
1>Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
1>_CopyAppConfigFile:
1>Skipping target "_CopyAppConfigFile" because all output files are up-to-date with respect to the input files.
1>CopyFilesToOutputDirectory:
1> ConsoleApplication1 -> H:\CSharp\TestRebuild\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe
1>
1>Build succeeded.
1>
1>Time Elapsed 00:00:00.07
========== Build: 1 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
Is this a bug? Is there a workaround?