Skip to content

Latest commit

 

History

History
59 lines (45 loc) · 2.38 KB

File metadata and controls

59 lines (45 loc) · 2.38 KB
title NuGet Error NU1008
description NU1008 error code
author nkolev92
ms.author nikolev
ms.date 11/07/2022
ms.topic reference
f1_keywords
NU1008

NuGet Error NU1008

The following PackageReference items cannot define a value for Version: PackageName. Projects using Central Package Management must define a Version value on a PackageVersion item.

Issue

A project is configured to use NuGet Central Package Management and a <PackageReference /> item is defined which specifies a value for the Version attribute:

<ItemGroup>
  <PackageReference Include="PackageName" Version="5.1.0" />
</ItemGroup>

Alternatively, a <PackageReference /> item is defined with a child <Version /> element that has a value specified:

<ItemGroup>
  <PackageReference Include="PackageName">
    <Version>5.1.0</Version>
  </PackageReference>
</ItemGroup>

Projects configured to use Central Package Management should not define a version on <PackageReference /> items. The version should be defined in on a corresponding <PackageVersion /> item with the same identifier in Directory.Packages.props file instead.

Solution

  • Remove the Version attribute or child <Version /> element from the <PackageReference /> item:

    <ItemGroup>
      <PackageReference Include="PackageName" />
    </ItemGroup>
  • Define a <PackageVersion /> item that specifies the version in the Directory.Packages.props file with the same identifier as the <PackageReference /> item:

    <ItemGroup>
      <PackageVersion Include="PackageName" Version="5.0.1" />
    </ItemGroup>

Alternatively, Central Package Management allows overriding centrally defined package versions. See Overriding Package Versions for more information.

Note

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