-
Notifications
You must be signed in to change notification settings - Fork 496
Improve pruning documentation #3444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Learn Build status updates of commit 8dbbe05: ✅ Validation status: passed
For more details, please refer to the build report. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Learn Build status updates of commit 080bf37: ✅ Validation status: passed
For more details, please refer to the build report. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Learn Build status updates of commit d9353cf: ✅ Validation status: passed
For more details, please refer to the build report. |
Learn Build status updates of commit c89c504: ✅ Validation status: passed
For more details, please refer to the build report. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a few suggestions that make it a little easier for me to read, but maybe it's worse for other people 😁
Co-authored-by: Andy Zivkovic <zivkan@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves the documentation for NuGet's PrunePackageReference feature by clarifying its behavior for direct PackageReference items and updating warning conditions. The changes address several GitHub issues by providing clearer guidance on when warnings are raised and how the pruning mechanism works.
- Clarifies that NU1510 and NU1511 warnings are only raised when projects target .NET 10 or newer
- Documents the pruning behavior for direct PackageReference items with detailed examples
- Updates the main PrunePackageReference documentation to explain both transitive and direct package handling
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
docs/reference/errors-and-warnings/NU1511.md | Adds note clarifying warning is only raised for .NET 10+ projects |
docs/reference/errors-and-warnings/NU1510.md | Expands documentation with multiple examples and clarifies when warning is raised |
docs/consume-packages/Package-References-in-Project-Files.md | Updates PrunePackageReference section to document direct package behavior and provide comprehensive examples |
Learn Build status updates of commit f1f3133: ✅ Validation status: passed
For more details, please refer to the build report. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Learn Build status updates of commit aca1826: ✅ Validation status: passed
For more details, please refer to the build report. |
Learn Build status updates of commit 789af58: ✅ Validation status: passed
For more details, please refer to the build report. |
Trying to better understand pruning (and NU1510), and how it relates to this document. When doing |
That sounds like an add package issue, rather than something specific to the pruning warning.
That's unusual, that shouldn't be the case. Similarly please file an issue about that (dotnet/sdk repo for this one) |
Done |
@@ -489,16 +491,53 @@ The .NET SDK predefines the list of packages to be pruned for you. | |||
|
|||
### How PrunePackageReference works | |||
|
|||
When a package is specified to be pruned during restore, it is removed from the dependency graph. This package is not downloaded and does not appear in any of the outputs of NuGet. When a package is pruned, there is a detailed verbosity message indicating that the package has been removed for the given target framework. | |||
When a package is specified to be pruned during restore, it is removed from the dependency graph. | |||
When a package is pruned, there is a message, visible at detailed verbosity, indicating that the package has been removed for the given target framework. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this for preview 7+? I don't see this with preview 6. (And I need to set -tl:off to see anything interesting with dotnet build
otherwise I just see the really compact build output)
Interestingly if I target .NET 8 I see
Task "GetPackagesToPrune"
Loading packages to prune for .NETCoreApp 8.0 Microsoft.NETCore.App
Loaded prune package data from framework packages
Done executing task "GetPackagesToPrune".
But when I target .NET 10 I see
Task "GetPackagesToPrune"
Loading packages to prune for .NETCoreApp 10.0 Microsoft.NETCore.App
Loading prune package data from PrunePackageData folder
Failed to load prune package data from PrunePackageData folder, loading from targeting packs instead
Looking for targeting packs in C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref
Pack directories found: C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\10.0.0-preview.6.25358.103
Found package overrides file C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\10.0.0-preview.6.25358.103\data\PackageOverrides.txt
Done executing task "GetPackagesToPrune".
I don't see System.Memory.dll in either bin folder (when System.Memory is transitively referenced via Azure.Identity@1.14.2) (not when targeting .NET 7 either) maybe that's expected?
And direct deps if I add just System.Memory directly isn't "fully" pruned as we discussed below and doesn't show up either. And NU1510 is triggered which says it will not be pruned. So line 497 isn't really what I see either?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, nice improvements/clarifications appreciated the examples and the updated table.
Fixes NuGet/Home#14410
Fixes NuGet/Home#14330
Fixes NuGet/Home#14254
Original spec for what was documented already: https://github.com/NuGet/Home/blob/dev/accepted/2024/prune-package-reference.md, https://github.com/NuGet/Home/blob/dev/accepted/2025/prune-package-reference-rollout.md was also part of the original documentation.
https://github.com/NuGet/Home/blob/dev/accepted/2025/PrunePackageReference-with-direct-PackageReference.md is the majority of the updates.