Skip to content

Possible bug: package pruning drops a centrally pinned dependency for a ProjectReference #15148

Open

Description

@denisbredikhin

NuGet Product Used

dotnet.exe

Product Version

  • .NET SDK: 11.0.100 - NuGet client: 8.x - MSBuild: 18.12.2-1.26529.118+297acf930 - Target framework: net10.0 for all projects

Worked before?

No response

Impact

It's more difficult to complete my work

Repro Steps & Context

To reproduce, create a class library and two small ASP.NET Core SDK applications.

Library/
  net10.0 class library
  references Polly.RateLimiting 8.7.0
ProjectConsumer/
  net10.0 Microsoft.NET.Sdk.Web application
  references Library.csproj with ProjectReference
PackageConsumer/
  net10.0 Microsoft.NET.Sdk.Web application
  references the packed Library package with PackageReference (in local feed)
Directory.Packages.props

Both applications call the same library method. It exercises the System.Threading.RateLimiting API and prints True if the method runs successfully.

The library has a PackageReference to Polly.RateLimiting 8.7.0, which depends on System.Threading.RateLimiting version 8.0.0 or later.

The solution enables central package management and pins System.Threading.RateLimiting to 11.0.0, with central transitive pinning enabled:

<Project>
  <PropertyGroup>
    <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
    <CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
  </PropertyGroup>
  <ItemGroup>
    <PackageVersion Include="Polly.RateLimiting" Version="8.7.0" />
    <PackageVersion Include="System.Threading.RateLimiting" Version="11.0.0" />
    <PackageVersion Include="PruningPinning.Repro.Library" Version="1.0.0" />
  </ItemGroup>
</Project>

Central transitive pinning raises Polly's transitive RateLimiting dependency to 11.0.0. Packing Library produces a .nuspec that declares System.Threading.RateLimiting 11.0.0.

To reproduce, restore/build both applications with the default package-pruning setting.
The ProjectConsumer build reports MSB3277 for the conflict between System.Threading.RateLimiting 10.0.0.0 from the ASP.NET Core reference pack and v11.0.0 required by the compiled library. If the warning is not promoted to an error, the build completes, but running the app throws FileNotFoundException because System.Threading.RateLimiting v11.0.0 is unavailable.

The PackageConsumer build has no MSB3277 warning. Its output contains System.Threading.RateLimiting 11.0.0, and the app runs successfully.

As a control, disabling package pruning lets the ProjectConsumer build without MSB3277 and run
successfully as well.

Expected: Both applications should be able to use the same library successfully, regardless of
whether it is referenced as a project or as a package.

Possible cause

The difference may be caused by when package pruning is applied relative to central transitive
pinning. Packing the library records its promoted v11 dependency in the .nuspec, and the
package-reference consumer restores that dependency. In the project-reference case, the assets list
Polly as the library's dependency but omit RateLimiting v11, even though the compiled library needs
it. This may indicate that pruning removes Polly's transitive dependency before the central pin is
propagated for a project reference.

Verbose Logs

Activity

  1. jebriede commented on Nov 17, 2026

    @jebriede
    Contributor

    I reproduced this with SDK 11.0.100.

    With default package pruning, the ProjectReference consumer’s project.assets.json lists Polly.RateLimiting 8.7.0 as the library’s dependency, but not System.Threading.RateLimiting 11.0.0. Its build reports MSB3277 for the conflict between 10.0.0.0 from the ASP.NET Core reference pack and 11.0.0.0. Running the consumer throws FileNotFoundException for System.Threading.RateLimiting, Version=11.0.0.0.

    With a PackageReference, the assets file lists System.Threading.RateLimiting 11.0.0 as a library dependency. With package pruning disabled, the ProjectReference build does not report MSB3277.

  2. added
    Area:PackagePruning
    Priority:2
    on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area:PackagePruningArea:RestoreCPMTransitiveDependenciesFunctionality:RestorePriority:2Type:Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions