-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Issue Description
Normal development operations can result in MSBuild and Visual Studio deciding that a project is up to date and skipping its build, resulting in debugging or running tests on code that doesn't include the latest changes.
A workaround is available: #6917 (comment)
Steps to Reproduce
In a solution with three class libraries, C referencing B referencing A, all using reference assemblies (targeting .NET 5.0+):
- Build solution.
- Make changes to project C.
- Build.
- Make internal changes to source files of project B.
- Build in Visual Studio.
Expected Behavior
Projects B and C build; B.dll
in the bin
folder of C is the latest version.
Actual Behavior
Only project B builds, project C is considered up to date with a log entry like
3>FastUpToDate: Output marker 'C:\Users\raines\source\repos\IncrementalUnderbuild\C\obj\Debug\net5.0\C.csproj.CopyComplete' does not exist, skipping marker check. (C)
Analysis
This is happening because IncrementalClean
will delete the .CopyComplete
marker file on a build that didn't need to copy references because they were all up-to-date (the build from step 3 that affected only C).
That's happening because the marker is only added to the @(FileWrites)
item (which means "files that would have been created by a clean build of this project") if it needed to be touched:
msbuild/src/Tasks/Microsoft.Common.CurrentVersion.targets
Lines 4834 to 4838 in bbb9655
<Touch Files="@(CopyUpToDateMarker)" | |
AlwaysCreate="true" | |
Condition="'@(ReferencesCopiedInThisBuild)' != '' and '$(WroteAtLeastOneFile)' == 'true'"> | |
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" /> | |
</Touch> |
So IncrementalClean
decided it was a stale output and decided to delete it.
That bug has been present for a very long time (since #2878) but was masked by #6576, which caused the marker to be touched any time the project built. Since that was fixed in Visual Studio 16.11.4, it revealed this (worse!) bug.