-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IncrementalClean can delete a needed file from output #9709
Comments
What is the recommended workaround? / @KirillOsenkov How do you workaround this bug? I think I am hitting this in an indirect way due to how Microsoft.Data.SqlClient.SNI imports native files in a net462 context. Technically, this is the guidance recommended by Microsoft. See https://learn.microsoft.com/en-us/nuget/create-packages/native-files-in-net-packages#projects-targeting-net-framework I think the generalization is you don't need "If a project has its output directory outside the project directory" to reproduce this problem. Any clean checkout that transitively imports targets from a nuget package under I've tested:
|
I just add If I need to clean I just git clean -xdf |
and yes, Microsoft.Data.SqlClient.SNI is a poorly authored NuGet package, might consider setting ExcludeAssets="all" PrivateAssets="all" GeneratePathProperty="true" and manually consuming the parts you need |
If a project has its output directory outside the project directory, and it copies a dependent file to output for more than one reason (say, via None as well as via RAR), and you remove one reason, building the project deletes the file from output, even though the file still needs to be there. Building the project again brings the file back.
C:\temp\IncrementalClean
or any other empty directory: IncrementalClean.zipmsbuild /r
C:\temp\IncrementalClean\bin\B\A.dll
exists (hereafter it's just called "The File")C:\temp\IncrementalClean\B\B.csproj
and comment out line 13 (to ensure the None item is not added), save filemsbuild
IncrementalBuild
targetmsbuild
This is because
@(ReferenceCopyLocalPaths)
is not added to@(FileWrites)
, it is added to@(FileWritesShareable)
. If a .dll is copied to output because it was in@(ReferenceCopyLocalPaths)
, it is not added toB.csproj.FileListAbsolute.txt
.In our repro, The File was added to FileListAbsolute.txt during step 2, because the
None
items added it to@(FileWrites)
. In step 5, the file is still copied by_CopyFilesMarkedCopyLocal
, but since it's no longer in@(FileWrites)
, but it is in@(_CleanPriorFileWrites)
,IncrementalClean
deletes it. In step 8 The File is copied back by_CopyFilesMarkedCopyLocal
, but since it's neither in current nor prior file writes, IncrementalClean doesn't delete it.Basically I'd say it's an unfortunate confluence of the output directory being outside the project cone and
FileWritesShareable
not being added toFileWrites
. I think this is the problematic logic that assumes the bin folder is inside the project directory:msbuild/src/Tasks/Microsoft.Common.CurrentVersion.targets
Lines 5615 to 5627 in 07fd5d5
I doubt there's a safe fix that we can do to fix the bug but I'm filing it just the same.
The text was updated successfully, but these errors were encountered: