NuGet Error NU1008

Projects that use central package version management should not define the version on the PackageReference items but on the PackageVersion items: PackageId.

Issue

When using central package management, versions must be defined on the PackageVersion item.

In your project file, you may see:

<!-- In the project file. -->
<PackageReference Include="PackageId" Version="5.1.0" />

Solution

  • Remove the version from the PackageId PackageReference.
  • You may need to add or update the PackageVersion item for PackageId in Directory.Packages.props

Example:

<!-- In the project file. -->
<PackageReference Include="PackageId" />
<!-- In the Directory.Packages.props -->
<PackageVersion Include="PackageId" Version="5.1.0" />

Note

Note that metadata such as IncludeAssets, PrivateAssets etc. should remain on the PackageReference item.