Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Scenario
PackageReference System.Text.Json will not be pruned. Consider removing this package from your dependencies, as it is likely unnecessary.
Issue
This warning is raised as a result of NuGet dependency graph pruning, and indicates that an otherwise prunable package was restored due to a direct PackageReference.
The named package can be pruned if the direct PackageReference is removed, since the targeted .NET SDK provides the same version or higher of this assembly.
This warning only affects packages registered for pruning through the PrunePackageReference feature.
It is only raised when the PackageReference in question can be completely removed from the project.
Example 1
When the targeted .NET SDK includes an equivalent version, dependency conflict resolution selects the SDK-bundled assembly:
<PropertyGroup>
<!-- 'System.Text.Json' is SDK-bundled in 'net10.0' -->
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<!-- The assembly provided by this reference will not be used -->
<PackageReference Include="System.Text.Json" Version="10.0.0" />
</ItemGroup>
Example 2
When the targeted .NET SDK includes an equivalent version for multiple framework targets, dependency conflict resolution selects the appropriate SDK-bundled assembly for each target:
<PropertyGroup>
<!-- 'System.Text.Json' is SDK-bundled in both TFMs -->
<TargetFrameworks>net9.0;net10.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<!-- Neither of the assemblies provided by these references will be used -->
<PackageReference Include="System.Text.Json" Version="10.0.0" Condition="'$(TargetFramework)' == 'net10.0'"/>
<PackageReference Include="System.Text.Json" Version="9.0.4" Condition="'$(TargetFramework)' == 'net9.0'"/>
</ItemGroup>
Solution
Remove the unnecessary PackageReference.
Note
Beginning with .NET 10, the PrunePackageReference feature is enabled by default for all projects that target .NET 10 or higher. The warning is only raised when pruning applies to all runtime targets:
<PropertyGroup>
<!-- 'System.Text.Json' is not SDK-bundled in 'net48' -->
<TargetFrameworks>net10.0;net48</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<!-- This reference is needed in 'net48' - NU1510 is not raised -->
<PackageReference Include="System.Text.Json" Version="9.0.7" />
</ItemGroup>