Edit

Share via


NuGet Warning NU1509

Scenario 1

Duplicate 'PrunePackageReference' items found. Remove the duplicate items or use the Update functionality to ensure a consistent restore behavior. The duplicate 'PrunePackageReference' items are: X 1.0.0, X 2.0.0.

Issue

Sometimes when adding PrunePackageReference items, you may end up adding an item for a particular package multiple times.

MSBuild projects commonly import multiple .props and .targets files, so the duplicates might not be in the same file, but may be in imported files, such as Directory.Build.props, Directory.Packages.props, or Directory.Build.targets.

The .NET SDK provides a of list PrunePackageReference, so the conflict may be happening because you have specified a PrunePackageReference or due to a bug with the .NET SDK.

Solution

Remove the duplicate item, so that it's included exactly once.