Skip to content
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

[Feature Request]: Add CopyExact to compliment PreserveNewest and CopyAlways #9350

Open
zivkan opened this issue Oct 20, 2023 · 2 comments
Open
Labels
Feature Request needs-design Requires discussion with the dev team before attempting a fix. Priority:2 Work that is important, but not critical for the release triaged
Milestone

Comments

@zivkan
Copy link
Member

zivkan commented Oct 20, 2023

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

@zivkan zivkan added Feature Request needs-triage Have yet to determine what bucket this goes in. labels Oct 20, 2023
@AR-May AR-May added needs-design Requires discussion with the dev team before attempting a fix. Priority:2 Work that is important, but not critical for the release and removed needs-triage Have yet to determine what bucket this goes in. labels Oct 24, 2023
@AR-May AR-May added this to the .NET 9.0 milestone Oct 24, 2023
@AR-May
Copy link
Member

AR-May commented Oct 24, 2023

MSBuild triage: Note for the design: be aware about app config file. Do not opt in the suggested behavior for it.

@KalleOlaviNiemitalo
Copy link

This is the same as #8743.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request needs-design Requires discussion with the dev team before attempting a fix. Priority:2 Work that is important, but not critical for the release triaged
Projects
None yet
Development

No branches or pull requests

4 participants