admin管理员组

文章数量:1279049

Just in the process of converting our legacy application (.NET 4.8) to use Central Package Management instead of the individual packages.json files.

I used the .NET Upgrade Assistant for most of the heavy lifting.

Everything appears to have worked correctly. I see the Directory.Packages.props has been generated in the root (same directory as the solution) of the repository.

All projects (.csproj) now have the their correct PackageReference's, e.g.,

<ItemGroup>
    <PackageReference Include="System.ValueTuple" />
</ItemGroup>

The generated Directory.Packages.props has the following structure:

<Project>
  <PropertyGroup>
    <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
    <CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
  </PropertyGroup>
  </ItemGroup>
    <PackageVersion Include="System.ValueTuple" Version="4.5.0" />
    ...Many other package versions
  </ItemGroup>
</Project>

Problem

Anytime I add a new Nuget package in Visual Studio via VS Package Manager UI, that package is not being added to the Directory.Packages.props file. Furthermore the individual PackageReference added to the project (.csproj) contain a version.

<PackageReference Include="Humanizer">
    <Version>2.14.1</Version>
</PackageReference>

I'm unsure why this new package is not being added to the Directory.Packages.props file and I also don't understand why the package is being added to the .csproj with a version.

We're using the following versions:

  • Visual Studio 2022 Enterprise v17.11.2
  • Nuget 6.11.0
  • Installed dotnet version: 8.0.400

All of our C# projects are targeting .NET Framework 4.8.

Just in the process of converting our legacy application (.NET 4.8) to use Central Package Management instead of the individual packages.json files.

I used the .NET Upgrade Assistant for most of the heavy lifting.

Everything appears to have worked correctly. I see the Directory.Packages.props has been generated in the root (same directory as the solution) of the repository.

All projects (.csproj) now have the their correct PackageReference's, e.g.,

<ItemGroup>
    <PackageReference Include="System.ValueTuple" />
</ItemGroup>

The generated Directory.Packages.props has the following structure:

<Project>
  <PropertyGroup>
    <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
    <CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
  </PropertyGroup>
  </ItemGroup>
    <PackageVersion Include="System.ValueTuple" Version="4.5.0" />
    ...Many other package versions
  </ItemGroup>
</Project>

Problem

Anytime I add a new Nuget package in Visual Studio via VS Package Manager UI, that package is not being added to the Directory.Packages.props file. Furthermore the individual PackageReference added to the project (.csproj) contain a version.

<PackageReference Include="Humanizer">
    <Version>2.14.1</Version>
</PackageReference>

I'm unsure why this new package is not being added to the Directory.Packages.props file and I also don't understand why the package is being added to the .csproj with a version.

We're using the following versions:

  • Visual Studio 2022 Enterprise v17.11.2
  • Nuget 6.11.0
  • Installed dotnet version: 8.0.400

All of our C# projects are targeting .NET Framework 4.8.

Share Improve this question edited Feb 24 at 0:14 WBuck asked Feb 23 at 20:41 WBuckWBuck 5,5112 gold badges29 silver badges46 bronze badges 2
  • i don't think thats supported in framework projects. – Daniel A. White Commented Feb 24 at 0:17
  • @DanielA.White I haven't read anything saying it isn't supported. If it's not I'm annoyed that it wasn't explicitly stated anywhere. – WBuck Commented Feb 24 at 12:21
Add a comment  | 

1 Answer 1

Reset to default 0

Unfortunately at the time of this writing (2025-02-24) Central Package Management (CPM) does not support the old style csproj, so in essence .NET Framework projects are not supported.

[Feature]: Add support for central package management to Visual Studio Package Manager UI for legacy projects

本文标签: cUnable to get Central Package Management (CPM) to work as expectedStack Overflow