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
The package System.Text.Json
has been specified for pruning through the PrunePackageReference feature.
The .NET SDK
generally specifies the list of packages to be pruned. The package is not needed as a direct PackageReference since the .NET runtime itself carries either the same or higher version of the assembly.
This warning is only raised when the PackageReference in question can be completely removed from the project.
Example 1
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Text.Json" Version="10.0.0" />
</ItemGroup>
Example 2
<PropertyGroup>
<TargetFrameworks>net9.0;net10.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Condition="'$(TargetFramework)' == 'net10.0'" Include="System.Text.Json" Version="10.0.0" />
<PackageReference Condition="'$(TargetFramework)' == 'net9.0'" Include="System.Text.Json" Version="9.0.0" />
</ItemGroup>
Each conditional PackageReference
for the System.Text.Json
package can be removed because the package is already included in the respective .NET runtime versions for the frameworks it is declared for.
Example 3
<PropertyGroup>
<TargetFrameworks>net9.0;net10.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Condition="'$(TargetFramework)' == 'net9.0'" Include="System.Text.Json" Version="9.0.4" />
</ItemGroup>
The System.Text.Json
package is within the pruning range of the only framework it's declared for.
Solution
Remove the PackageReference as it's unnecessary.
Note
In order to allow for easier adoption of the PrunePackageReference feature, this warning is raised by default when a project targets the .NET 10 framework or newer.
Note
The warning will not be raised in scenarios in which at least one of the frameworks still needs the package, such as net48
in the below example.
<PropertyGroup>
<TargetFrameworks>net10.0;net48</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Text.Json" Version="9.0.7" />
</ItemGroup>