[Feature Request]: Add CopyExact
to compliment PreserveNewest
and CopyAlways
#9350
Labels
Feature Request
needs-design
Requires discussion with the dev team before attempting a fix.
needs-more-info
Issues that need more info to continue investigation.
Priority:2
Work that is important, but not critical for the release
triaged
Milestone
Summary
PreserveNewest
makes a lot of sense for projects being compiled, however, it causes problems when changing package versions to a package which is older than the one previously used. Currently, it's necessary to clean the output directory to make this scenario work.Background and Motivation
Root cause of this issue: NuGet/Home#12955
The customer is running
dotnet publish
on their sln file, with the-o
parameter, so all projects in the solution are being published to the same directory. MSBuild is doing the right thing and publishing projects in order of the project graph. The first project references a package with an older package version, but was compiled & published more recently than the newer package version. Therefore, whatever.dll from the lower package version has a newer timestamp than the same dll from the higher package version.I don't know if it's the .NET SDK or msbuild, but in any case
PreserveNewest
is being used, and as a result, the lower assembly version is being retained in the publish directory, leading to a runtime failure.Proposed Feature
MSBuild should introduce a new "copy to" semantic for "copy if the timestamps are not an exact match". Afterwards, I imagine that the .NET SDK and NuGet.BuildTools need to be modified to use the new enum value for assemblies (and other assets?) coming from packages, to ensure that when older packages are used, the files from the currently referenced package is used.
An alternative is that assets from packages should use
CopyAlways
, but that might harm build performance when the copy is unnecessary.Alternative Designs
No response
The text was updated successfully, but these errors were encountered: