Skip to content

Failed to build when using central package version management (CPVM) #2213

Open
@flobernd

Description

@flobernd

My project is using the new central package version management feature (Directory.Packages.props in the root directory). If this feature is enabled, it's not allowed to specify a package version in a <PackageReference> tag.

BenchmarkDotNet build fails, because of this:

 Standard error:
   Determining projects to restore...
[...]\bin\Release\net7\a26f5fd8-3b2f-4716-a61f-af4e51ccb248\BenchmarkDotNet.Autogenerated.csproj : error NU1008: Projects that use central package version management should not define the version on the PackageReference items but on the PackageVersion items: Microsoft.DotNet.ILCompiler.

It can be fixed on your side by auto-generating a Directory.Packages.props in the output directory (e.g. \bin\Release\net7\a26f5fd8-3b2f-4716-a61f-af4e51ccb248 in this example) with the following content:

<!-- https://devblogs.microsoft.com/nuget/introducing-central-package-management/ -->
<Project>
  <PropertyGroup>
    <ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
  </PropertyGroup>
</Project>

This will disable the CPVM feature for all projects inside the output directory (recursively).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions