Skip to content

[Breaking change]: PrunePackageReference, direct PackageReference that can be pruned are marked with PrivateAssets=all and IncludeAssets=none automatically. #47292

Open
@nkolev92

Description

@nkolev92

Description

Design NuGet/Home#14325

PrunePackageReference which is enabled in .NET 10 SDK for all .NET Core App 3.0 and newer automatically removes transitive packages that would be provided by the platform.

Starting with .NET 10 P7, the directly prunable PackageReference will be automatically marked with PrivateAssets=all and IncludeAssets=none.

Pruning docsa: https://learn.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files#prunepackagereference

Version

Other (please put exact version in description textbox)

Previous behavior

.NET 10 Preview 6, nothing happened to direct PackageReference that are in the pruning range. You may get an NU1510 warning.

  <PropertyGroup>
    <TargetFramework>net9.0;net472</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="System.Text.Json" Version="9.0.4" />
  </ItemGroup>
```xml 

Generates a package with the following nuspec: 

```xml
<dependencies>
    <group targetFramework=".NETFramework4.7.2">
        <dependency id="System.Text.Json" version="9.0.4" />
    </group>
    <group targetFramework="net9.0">
        <dependency id="System.Text.Json" version="9.0.4" />
    </group>
</dependencies>

New behavior

  <PropertyGroup>
    <TargetFramework>net9.0;net472</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="System.Text.Json" Version="9.0.4" />
  </ItemGroup>
```xml 

Generates a package with the following nuspec: 

```xml
<dependencies>
    <group targetFramework=".NETFramework4.7.2">
        <dependency id="System.Text.Json" version="9.0.4" />
    </group>
    <group targetFramework="net9.0">
    </group>
</dependencies>

Type of breaking change

  • Binary incompatible: Existing binaries might encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
  • Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code might require source changes to compile successfully.
  • Behavioral change: Existing binaries might behave differently at run time.

Reason for change

These PackageReference are unnecessary since the needed APIs are available within the runtime anyways.

Recommended action

If you get NU1510, follow the instructions there.
If you don't get an NU1510, if the nuspec is not containing the PackageReference in question in any of the frameworks, remove it from the project.
If it is still somewhere in the nuspec, then no action needed.

Feature area

Other (please put exact area in description textbox)

Affected APIs

.NET SDK


Associated WorkItem - 454112

Metadata

Metadata

Assignees

Labels

📌 seQUESTeredIdentifies that an issue has been imported into Quest.breaking-changeIndicates a .NET Core breaking change

Type

No type

Projects

Status

🔖 Ready

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions