NuGet "NU1008: Projects that use central package management" in CI
Central Package Management (CPM) is enabled, so package versions must live in Directory.Packages.props as PackageVersion items - not inline on each PackageReference. NU1008 fires when a project still pins a version on the reference itself.
What this error means
Restore fails with NU1008 listing the offending PackageReference items that still carry a Version attribute. It is deterministic - it reproduces every run until the inline versions are removed and centralized.
error NU1008: Projects that use central package management should not define the version
on the PackageReference items but the PackageReference for 'Serilog' defines a version.Common causes
A PackageReference still pins a version under CPM
With ManagePackageVersionsCentrally set to true, NuGet expects the version to come from a central PackageVersion. A leftover Version= on a PackageReference is rejected as a conflict.
A project was migrated to CPM but not fully cleaned up
When a solution adopts Directory.Packages.props, individual .csproj files must drop their inline versions. One that still has them trips NU1008.
How to fix it
Move the version into Directory.Packages.props
Declare the version centrally and leave the project reference version-less.
<!-- Directory.Packages.props -->
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Serilog" Version="4.1.0" />
</ItemGroup>
</Project>Strip the inline version from the reference
In the project, reference the package by id only - the version is resolved centrally.
<!-- MyApp.csproj -->
<ItemGroup>
<PackageReference Include="Serilog" />
</ItemGroup>How to prevent it
- Keep all versions in
Directory.Packages.propsonce CPM is enabled. - When migrating to CPM, sweep every
.csprojfor leftover inline versions. - Use
VersionOverride(notVersion) for the rare per-project exception.
Frequently asked questions
How do I override a single project’s version under CPM?
<PackageReference Include="X" VersionOverride="1.2.3" />. A plain Version attribute is what triggers NU1008; VersionOverride is the supported way to deviate from the central version.