Skip to content

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

Merged
merged 8 commits into from
Jul 23, 2025
Merged

Conversation

nkolev92
Copy link
Member

@nkolev92 nkolev92 commented Jul 17, 2025

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.

  • Document the pruning behavior for direct PackageReference.
  • Clarify that NU1510 & NU1511 are only raised when the project targets .NET 10.
  • Add more examples to the NU1510 page to improve clarity for when the warning is being raised.

Copy link

Learn Build status updates of commit 8dbbe05:

✅ Validation status: passed

File Status Preview URL Details
docs/consume-packages/Package-References-in-Project-Files.md ✅Succeeded View
docs/reference/errors-and-warnings/NU1510.md ✅Succeeded View
docs/reference/errors-and-warnings/NU1511.md ✅Succeeded View

For more details, please refer to the build report.

@nkolev92 nkolev92 marked this pull request as ready for review July 17, 2025 18:51
@Copilot Copilot AI review requested due to automatic review settings July 17, 2025 18:51
@nkolev92 nkolev92 requested review from a team as code owners July 17, 2025 18:51
Copilot

This comment was marked as outdated.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link

Learn Build status updates of commit 080bf37:

✅ Validation status: passed

File Status Preview URL Details
docs/consume-packages/Package-References-in-Project-Files.md ✅Succeeded View
docs/reference/errors-and-warnings/NU1510.md ✅Succeeded View
docs/reference/errors-and-warnings/NU1511.md ✅Succeeded View

For more details, please refer to the build report.

@nkolev92 nkolev92 requested a review from Copilot July 18, 2025 00:38
Copilot

This comment was marked as outdated.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@nkolev92 nkolev92 requested a review from Copilot July 18, 2025 00:41
Copilot

This comment was marked as outdated.

Copy link

Learn Build status updates of commit d9353cf:

✅ Validation status: passed

File Status Preview URL Details
docs/consume-packages/Package-References-in-Project-Files.md ✅Succeeded View
docs/reference/errors-and-warnings/NU1510.md ✅Succeeded View
docs/reference/errors-and-warnings/NU1511.md ✅Succeeded View

For more details, please refer to the build report.

Copy link

Learn Build status updates of commit c89c504:

✅ Validation status: passed

File Status Preview URL Details
docs/consume-packages/Package-References-in-Project-Files.md ✅Succeeded View
docs/reference/errors-and-warnings/NU1510.md ✅Succeeded View
docs/reference/errors-and-warnings/NU1511.md ✅Succeeded View

For more details, please refer to the build report.

@nkolev92 nkolev92 requested a review from Copilot July 18, 2025 00:48
Copilot

This comment was marked as outdated.

zivkan
zivkan previously approved these changes Jul 18, 2025
Copy link
Member

@zivkan zivkan left a 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>
Copy link

@Copilot Copilot AI left a 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

Copy link

Learn Build status updates of commit f1f3133:

✅ Validation status: passed

File Status Preview URL Details
docs/consume-packages/Package-References-in-Project-Files.md ✅Succeeded View
docs/reference/errors-and-warnings/NU1510.md ✅Succeeded View
docs/reference/errors-and-warnings/NU1511.md ✅Succeeded View

For more details, please refer to the build report.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@nkolev92 nkolev92 requested a review from zivkan July 18, 2025 17:18
Copy link

Learn Build status updates of commit aca1826:

✅ Validation status: passed

File Status Preview URL Details
docs/consume-packages/Package-References-in-Project-Files.md ✅Succeeded View
docs/reference/errors-and-warnings/NU1510.md ✅Succeeded View
docs/reference/errors-and-warnings/NU1511.md ✅Succeeded View

For more details, please refer to the build report.

@nkolev92 nkolev92 enabled auto-merge (squash) July 18, 2025 22:13
Copy link

Learn Build status updates of commit 789af58:

✅ Validation status: passed

File Status Preview URL Details
docs/consume-packages/Package-References-in-Project-Files.md ✅Succeeded View
docs/reference/errors-and-warnings/NU1510.md ✅Succeeded View
docs/reference/errors-and-warnings/NU1511.md ✅Succeeded View

For more details, please refer to the build report.

@Frulfump
Copy link

Trying to better understand pruning (and NU1510), and how it relates to this document.

When doing dotnet package add System.Memory@4.6.3 I see the warning text but colored as info and then as a real warning with yellow text during dotnet build or dotnet restore. The dotnet package add command seem to trigger an implicit build, I thought it was only an implicit restore first (and why only the --no-restore exists on it, should a --no-build be added or is it required somehow)
(.NET 10 preview 6, maybe some of this changes with dotnet/sdk#49635?)

@nkolev92
Copy link
Member Author

nkolev92 commented Jul 23, 2025

@Frulfump

When doing dotnet package add System.Memory@4.6.3 I see the warning text but colored as info

That sounds like an add package issue, rather than something specific to the pruning warning.
Can you please file an issue for that? (nuget/home repo)

The dotnet package add command seem to trigger an implicit build

That's unusual, that shouldn't be the case. Similarly please file an issue about that (dotnet/sdk repo for this one)

@nkolev92 nkolev92 merged commit d741831 into main Jul 23, 2025
2 checks passed
@nkolev92 nkolev92 deleted the dev-nkolev92-improvePruningDocumentation branch July 23, 2025 20:48
@Frulfump
Copy link

@Frulfump

When doing dotnet package add System.Memory@4.6.3 I see the warning text but colored as info

That sounds like an add package issue, rather than something specific to the pruning warning. Can you please file an issue for that? (nuget/home repo)

The dotnet package add command seem to trigger an implicit build

That's unusual, that shouldn't be the case. Similarly please file an issue about that (dotnet/sdk repo for this one)

Done

NuGet/Home#14443
dotnet/sdk#49921

@@ -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.
Copy link

@Frulfump Frulfump Jul 24, 2025

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?

Copy link

@Frulfump Frulfump left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants