error NU1008: The following PackageReference items cannot define a value for Version: Newtonsoft.Json. The project uses Central Package Management, where versions live in Directory.Packages.props, and a .csproj still carries its own Version attribute. Delete the attribute from the project file and keep the version in the central file.

Its companion, NU1010, is the opposite gap: a PackageReference with no matching PackageVersion in the central file. Add the PackageVersion line for it. Both came out of one restore in the test below.

The error

  Determining projects to restore...
...\CpmLab\CpmLab.csproj : error NU1008: The following PackageReference items cannot define a value for Version: Newtonsoft.Json. Projects using Central Package Management must define a Version value on a PackageVersion item. For more information, visit https://aka.ms/nuget/cpm/gettingstarted
...\CpmLab\CpmLab.csproj : error NU1010: The following PackageReference items do not define a corresponding PackageVersion item: Humanizer.Core. Projects using Central Package Management must declare PackageReference and PackageVersion items with matching names. For more information, visit https://aka.ms/nuget/cpm/gettingstarted

The project paths are shortened; nothing else in the output was changed.

Why it happens

ManagePackageVersionsCentrally set to true in a Directory.Packages.props above the project switched this project's restore to central mode. In that mode a PackageReference names the package only, and the version comes from the matching PackageVersion item in the central file. Restore refuses a reference that carries a version of its own (NU1008) and a reference with no central version at all (NU1010), and the restore failed in 50 ms without building anything.

In the test, Newtonsoft.Json had a version in both places, the central file and the project file, and Humanizer.Core was referenced without a central entry. The message names every offending package, so the list after the colon is your to-do list, one package per entry, and the fix below handles each entry in turn.

The fix

<Project>
  <PropertyGroup>
    <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
  </PropertyGroup>
  <ItemGroup>
    <PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
    <PackageVersion Include="Humanizer.Core" Version="2.14.1" />
  </ItemGroup>
</Project>

That is Directory.Packages.props; in CpmLab.csproj the references keep only their names:

<PackageReference Include="Newtonsoft.Json" /><PackageReference Include="Humanizer.Core" />
dotnet build
dotnet list package

The build then succeeded with 0 errors, and dotnet list package showed Humanizer.Core 2.14.1 and Newtonsoft.Json 13.0.3, both taken from the central file. From now on a version change in this project is an edit to its PackageVersion line in the central file, not to the project file, and the version attribute should never come back to the PackageReference items.

How it was reproduced

A dotnet new console project on .NET SDK 10.0.403 (net10.0) under a folder holding a Directory.Packages.props with ManagePackageVersionsCentrally true and one PackageVersion for Newtonsoft.Json 13.0.3. The project referenced Newtonsoft.Json with Version="13.0.3" and Humanizer.Core with no version. dotnet build failed with both errors.

Frequently asked

What does NU1008 PackageReference items cannot define a value for Version mean?
The project uses Central Package Management, so versions belong on PackageVersion items in Directory.Packages.props. A PackageReference in the csproj still has a Version attribute.
How do I fix NU1008?
Remove the Version attribute from the PackageReference items named in the message, and make sure Directory.Packages.props has a PackageVersion item with that version.
What is NU1010 do not define a corresponding PackageVersion item?
A PackageReference has no matching PackageVersion in Directory.Packages.props. Add a PackageVersion line with the package name and version to the central file.

More decoded errors in the Fixes category.