NU1505: Duplicate 'PackageDownload' items warning is raised when the SDK uses PackageDownload to get packages.
See original GitHub issueDescribe the bug
Recently NuGet added warnings for duplicate PackageReference/PackageDownload/PackageVersion items. Duplicate items could lead to an unpredictable behavior. You can learn about the motivation more in https://github.com/NuGet/Home/issues/9864. https://github.com/NuGet/Home/blob/dev/proposed/2022/duplicate-nuget-item-error-handling.md
NuGet added this in 6.0.400, so customers will start seeing this very soon.
To Reproduce
Originally filled in https://github.com/NuGet/Home/issues/11720.
- Use latest SDK with NuGet version 6.3.0 or higher. Might not be 100% inserted today.
- Create a .NET Core Console App, netcoreapp3.1. project with PackageReference package installed.
- Run “dotnet restore” in Developer Command Prompt for VS 2022 Preview
- The warning “warning NU1505: Duplicate ‘PackageDownload’ items found. Remove the duplicate items or use the Update functionality to ensure a consistent restore behavior.” occurs as below screenshot.
This was was discovered by the NuGet test team, @v-luzh Can you please post the csproj in question?
Why is this important?
NuGet will raise a warning when it sees duplicate items, and warning as errors could cause failures for customers.
Exceptions (if any)
Further technical details
- Include the output of
dotnet --info
- The IDE (VS / VS Code/ VS4Mac) you’re running on, and its version Latest main version of NuGet tooling will have this.
Issue Analytics
- State:
- Created a year ago
- Reactions:5
- Comments:33 (20 by maintainers)
Top Results From Across the Web
NuGet Warning NU1505
Duplicate 'PackageDownload' items found. Remove the duplicate items or use the Update functionality to ensure a consistent restore behavior.
Read more >Duplicate 'PackageReference' items found. Remove the ...
I am using Microsoft Visual Studio Community 2022 (64-bit) - Preview Version 17.3.0 Preview 1.1. enter image description here. Error Severity ...
Read more >Untitled
WebApr 7, 2022 · NU1505: Duplicate 'PackageDownload' items warning is raised when the SDK uses PackageDownload to get packages.
Read more >Install AWSSDK packages with NuGet - AWS SDK for .NET
NuGet is aware of dependencies between packages and installs all required packages automatically. Warning. The list of NuGet packages might include one named ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It’d be nice if this error message actually pointed to the file/source locations of the project/props/target files that are including these references. I hit this issue with the new warnings in our project, but I’m just referencing the SDK and such, so no idea where the extra package reference is coming from. Changed the PackageReference from
Include
toUpdate
for now to get around it… 🤷♂️Hey folks, we have a good idea what happened and what the path forward is now.
Cause
NuGet in VS is independent of the NuGet shipped with the SDK. The NuGet in VS has gotten ahead of the SDK, and it includes the additional validation for duplicate PackageDownloads and PackageReferences. As a result, when the NuGet in VS interacts with a project that uses an SDK that contains the PackageDownload duplication bug, these errors appear for users.
Mitigation
All of these duplicate checks are guarded by an MSBuild condition. If you set
DisableCheckingDuplicateNuGetItems
totrue
in your project files, the error should go away. You can also set the error codes toNoWarn
like so:<NoWarn>$(NoWarn);NU1505</NoWarn>
. Note that since the SDK has had this bug lying latent for a while, simply moving to an older SDK version will not remove the issue. Theoretically you could also move to preview releases of either the 6.0.400 or 7.0.100 SDKs and the issue would resolve itself as well, since the SDK was fixed on both of those branches.Resolution
The SDK will ship version 6.0.400 in VS 17.3, so it was just a matter of time until we did an insertion to that preview. We will accelerate our timeline and do the insertion early next week (after dotnet/installer#13827 merges). That will unblock the internal dogfood previews of 17.3 for internal Microsoft users. For the broader public, this will not be fixed until 17.3 Preview 2 is released, which should be roughly a month from now.