question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NU1505: Duplicate 'PackageDownload' items warning is raised when the SDK uses PackageDownload to get packages.

See original GitHub issue

Describe 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.

  1. Use latest SDK with NuGet version 6.3.0 or higher. Might not be 100% inserted today.
  2. Create a .NET Core Console App, netcoreapp3.1. project with PackageReference package installed.
  3. Run “dotnet restore” in Developer Command Prompt for VS 2022 Preview
  4. 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?

162154703-64f6f300-1ada-41d3-a092-d9da82d8fea2

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:closed
  • Created a year ago
  • Reactions:5
  • Comments:33 (20 by maintainers)

github_iconTop GitHub Comments

6reactions
michael-hawkercommented, Oct 17, 2022

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 to Update for now to get around it… 🤷‍♂️

5reactions
baronfelcommented, May 13, 2022

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 to true in your project files, the error should go away. You can also set the error codes to NoWarn 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found