You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference/errors-and-warnings/NU1510.md
+17-25Lines changed: 17 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,68 +17,60 @@ f1_keywords:
17
17
18
18
### Issue
19
19
20
-
The package `System.Text.Json` has been specified for pruning through the [PrunePackageReference](../../consume-packages/Package-References-in-Project-Files.md#prunepackagereference) feature.
21
-
The `.NET SDK` generally specifies the list of packages to be pruned. The package is not needed as a direct PackageReferencesince the .NET runtime itself carries either the same or higher version of the assembly.
20
+
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`.
21
+
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.
22
22
23
-
This warning is *only* raised when the PackageReference in question *can be completely removed from the project*.
23
+
This warning only affects packages registered for pruning through the [PrunePackageReference](../../consume-packages/Package-References-in-Project-Files.md#prunepackagereference) feature.
24
+
It is *only* raised when the `PackageReference` in question *can be completely removed from the project*.
24
25
25
26
#### Example 1
26
27
28
+
When the targeted .NET SDK includes an equivalent version, *dependency conflict resolution* selects the SDK-bundled assembly:
29
+
27
30
```xml
28
31
<PropertyGroup>
32
+
<!-- 'System.Text.Json' is SDK-bundled in 'net10.0' -->
29
33
<TargetFramework>net10.0</TargetFramework>
30
34
</PropertyGroup>
31
35
32
36
<ItemGroup>
37
+
<!-- The assembly provided by this reference will not be used -->
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.
51
-
52
-
#### Example 3
44
+
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:
53
45
54
46
```xml
55
47
<PropertyGroup>
48
+
<!-- 'System.Text.Json' is SDK-bundled in both TFMs -->
The `System.Text.Json` package is within the pruning range of the only framework it's declared for.
65
-
66
59
### Solution
67
60
68
-
Remove the PackageReference as it's unnecessary.
69
-
70
-
> [!NOTE]
71
-
> 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.
61
+
Remove the unnecessary `PackageReference`.
72
62
73
63
> [!NOTE]
74
-
> 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.
64
+
> 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:
75
65
>
76
66
> ```xml
77
67
> <PropertyGroup>
68
+
> <!-- 'System.Text.Json' is not SDK-bundled in 'net48' -->
0 commit comments