Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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.