-
Notifications
You must be signed in to change notification settings - Fork 258
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
Duplicate PackageReference includes are handled inconsistently by all restores, leading to unnecessary full restores #9864
Comments
Can we make it an error to have duplicated PackageReference items? This would break projects, but seems like saner behavior. The SDK already checks for a variety of duplicate items (Compile, FrameworkReference, etc) and errors if there are duplicates. |
The commandline scenarios would be easy. In VS, nomination that'd be problematic. I don't think the project-system can/should surface this error, rather it should be NuGet. That means NuGet needs to receive all the data. The IVsReferenceItem that represents a PR has a name, which suggests it should be unique. Thoughts @davkean? I'd have to investigate legacy to understand what happens there. |
Can you generate the error in the NuGet targets? Then you would have access to all the MSBuild items. |
That might work. |
Make |
Note, we cannot pass through the entire list of items to NuGet ourselves - the entire surface area in CPS is based on dictionaries and not a fair representation of the "list" concept in MSBuild. |
I have confirmed at least 2 other bugs to the same root cause. |
A precedent very much exists in https://github.com/dotnet/sdk/blob/44f381b62d466565639d51847c9127afbe7062a9/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.DefaultItems.targets#L284 :) I think the biggest concern here is how happy customers will be to suddenly start getting this error. :) |
Could this be introduced behind a warning wave? |
Can you elaborate what you mean by a warning wave? |
Looks like it's called a Change Wave in the docs: https://docs.microsoft.com/en-us/visualstudio/msbuild/change-waves?view=vs-2022 |
Hey all, Given that this can be a pretty impactful change, I have written up a proposal. The pull request for the proposal can be found at NuGet/NuGet.Client#4484. |
tldr of the proposal: When a NuGet item is seen as a duplicate, the first item is chosen and a warning is raised. NU1505 for PackageReference, NU1506 for PackageDownload, NU1507 for PackageVersion. We're also supporting ContinueOnError for VS purposes. |
Reviewed the proposal internally. |
Take a project such as the following:
Note the duplicate PackageReference declaration. Digging further reveals that different project types and different tools handle it differently.
See the below table for details
This leads to issues as the ones described in dotnet/arcade#5550 (see below repro).
I think logically from an msbuild perspective, we'd expect that the last value is the one that's resolved. This needs investigated and ideally consolidated.
Note that consolidating VS - LEgacy PR projects might be impossible, due to the fact that it's largely in maintenance mode.
See repro below.
cc folks that might have some thoughts around:
@jeffkl @davkean @dsplaisted @zivkan
fyi @sharwell @garath
DuplicateIds.zip
WIP:
Design: https://github.com/NuGet/Home/compare/dev-nkolev92-duplicatesHandling
Implementation: https://github.com/NuGet/NuGet.Client/tree/dev-nkolev92-duplicatePRs
The text was updated successfully, but these errors were encountered: