Edit

Share via


NuGet Error NU1011

The following PackageVersion items cannot specify a floating version: PackageName.

Issue

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

<ItemGroup>
  <PackageVersion Include="PackageName" Version="1.*" />
</ItemGroup>

By default, <PackageVersion /> items cannot specify floating versions. NuGet's Central Package Management provides users the ability to manage package versions in a single ___location as well as deterministic and secure restores. The use of floating versions introduces the possibility for a bad package to be introduced into your build after it has been pushed to a feed. This can lead to a situation where you made no changes in your repository but suddenly something is broken due to a problem in a new package and there is no way for you to get back into a good state without removing the floating version or pushing a newer version of the package which is fixed. Using non-floating versions means that every upgrade to a package is backed by a commit in your repository, making it easy to determine what change caused the break and allows you to revert a commit to get back into a good state.

Also, when using the transitive pinning feature of Central Package Management, using a floating version as an override could make restores of different projects end up with different versions for the package that what is supposed to be pinned, thus going against the promise of using the centrally defined version.

NuGet recommends you use automation like Dependabot to keep package versions up-to-date which provides a streamlined way of updating package versions while integrating into your existing developer workflow of a pull request, automated build validation, and testing all backed by a commit in your repository.

Solution

<ItemGroup>
  <PackageVersion Include="PackageName" Version="1.0.0" />
</ItemGroup>
  • If that is not possible, or you wish to use floating versions with Central Package Management, you can do so by setting an MSBuild property:
<PropertyGroup>
  <CentralPackageFloatingVersionsEnabled>true</CentralPackageFloatingVersionsEnabled>
</PropertyGroup>