Skip to content

Conversation

@nkolev92
Copy link
Member

Design for #14345.

@nkolev92 nkolev92 requested a review from a team as a code owner July 24, 2025 00:45
- Customers with builds that have customization may run into build failures if they are:
- Manually referencing an assembly or props/targets from a package from the global packages folder. Note that pruning is not allowed for direct dependencies, so this would need to be a transitive package.
- Manually copying assembly during a build - at runtime, the platform version will be preferred anyways, but it could lead to the build failing if the package cannot be found on disk anymore.
- We don't expect this to be a common scenario given that the packages being pruned are within the framework and customers do not need do to anything custom to make things work.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with that sentiment. We might need to react to this in the few repositories that build the shared frameworks: aspnetcore, runtime and windowsdesktop but I don't expect any other components to be significantly impacted.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, our repos are definitely the most complex ones from this perspective.

Copy link

@ViktorHofer ViktorHofer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great summary of the current state. I read through it and still believe that the option that we initially chose "> All .NET & .NET Standard 2.0 >=" is the right one.

I agree that we should fix the entries for frameworks that don't have a targeting pack and use the meta package concept: .NETCoreApp2.x and .NETStandard2.0. The latter might not be affected.

1. Reduces false positives by NuGet Audit, Component Governance and other dependency auditing tools.
Our data investigations show that up 30% of transitive vulnerabilities are within packages that may be removed by pruning.
This improves the confidence in NuGetAudit and reduces unnecessary alerts by scanners that do not ship as part of the .NET SDK tooling.
1. Improves performance, by virtue of having smaller dependency graphs and fewer packages downloaded.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't savings in size of deployments also a motiviation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, build time conflict resolution was already taking care of that.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the most part - as a side-effect of the pruning feature we changed/made-consistent the data used for conflict resolution which will help drop all major-version-matching packages. dotnet/sdk#44566

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.

I liked the overall pros/cons and learned a bit more about pruning while reading it as well.

- Enabling pruning for all .NET versions + .NET Standard 2.0+ (.NET 10 Preview 1 behavior)
- Enabling pruning for .NET 8+ and .NET Standard 2.0+ (proposed .NET 10 Preview 7 behavior)
- Enabling pruning for .NET 10 only (new)
- Enabling pruning when NuGetAuditMode is all. (new)

This comment was marked as resolved.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, added feature tangling causing confusion in the cons.

Pros:

- Enables pruning for all in support frameworks. Providing benefits to projects staying current.
- Does not address false positives for every customer currently getting false positive warnings (see example: <https://github.com/dotnet/sdk/issues/49226>).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hoping this will get addressed, false positives are highly annoying.

- NuGetAuditMode is gonna be direct for a large majority of existing projects (Only 1% of restores have NuGetAuditMode=all)
We will see reduction in downloads of these packages and reduction of these packages being part of newly published packages, but we won't necessarily reduce the warnings count (overall we do want to eliminate vulnerable package usage).
The primary benefit is prunable packages not appearing in newly published packages due to automatic PrivateAssets=all.
- We are making a TFM based enablement on the runtime supported, but that logic really only applies for applications, but pruning and audit are enabled for both apps and libraries. Library authors will often target lower version of the framework because that's all they need.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come the logic only applies for apps in this case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apps care about the runtime they're targeting and when a runtime goes out of support, they're likely to move their project to a newer runtime since they'll get a warning.

For libraries, the tfm targeted just defines the APIs is has available, but the questions around vulnerabilities are super relevant.

See some context in dotnet/sdk#28518.

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.

I didn't mention this prior but the different stats being provided is very interesting (and also very relevant)

donnie-msft
donnie-msft previously approved these changes Aug 8, 2025
aortiz-msft
aortiz-msft previously approved these changes Aug 8, 2025
@nkolev92 nkolev92 dismissed stale reviews from aortiz-msft and donnie-msft via 489f7d2 August 11, 2025 17:34
@nkolev92 nkolev92 merged commit 5fb1dc4 into dev Aug 11, 2025
1 check passed
@nkolev92 nkolev92 deleted the dev-nkolev92-pruningRolloutTake2 branch August 11, 2025 17:34
- Potential of a breaking change for pre-existing projects. However, the benefits for these customers are more obvious, since they are likely to see fewer vulnerability warnings. They made an explicit decision to adopt NuGetAudit, and they will likely be receptive of a feature improve NuGetAudit itself. (see example: <https://github.com/dotnet/sdk/issues/49226>)
- Features get a bit tangled and enabling one feature opting you into another one could cause confusion.

### >= .NET 10 enables pruning for all frameworks
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have explicitly called out .NETFramework. I thought we had previously decided that pruning on .NETFramework wasn't a good idea (which is why it was excluded in both past iterations), however it looks like the current implementation enables this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants