-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Improve pruned package data loading and handling #46898
base: main
Are you sure you want to change the base?
Conversation
…ing packages for them
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.
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
src/Tasks/Microsoft.NET.Build.Tasks/FrameworkPackages/FrameworkPackages.cs
Show resolved
Hide resolved
One important use-case are repositories that build shared frameworks (targeting packs) and consume them in their live build. These repositories need to be able to tell the SDK to use their live built targeting pack PackageOverrides.txt file. The current use of FWIW runtime uses this hook to tell the SDK to use the locally built packs: https://github.com/dotnet/runtime/blob/0004083b20a30dbb030aeb7e977feca0187c856c/eng/targetingpacks.targets#L119-L132 |
For repositories that build shared frameworks, is it important to prune packages? Do those repos have transitive references to packages that should be pruned? Is this problem specific to package overrides, or is it a general problem for using a repo-built targeting pack for one shared framework but also referencing another shared framework? How is that handled today? |
Yes, let me speak for runtime but this should also apply to aspnetcore and windowsdesktop. Runtime builds the live shared framework and then uses that to build the out-of-band package projects and tests. OOBs and test projects have external dependencies that bring transitives in that overlap with the framework assemblies. Those already caused CG issues in the past and it would be good to be able to use package pruning here.
This is specific to the PackageOverrides.txt file. The SDK offers all the hooks needed to point to live built packs. I.e. the PlatformManifest.txt and other data files are used from the live built SDK. |
I'll add that we want our repos to use the product in the best way possible -- that way our builds test what we ship to customers. The more custom we need to make our solution the more we have to maintain and we lose valuable coverage of the SDK features. |
<Output TaskParameter="PackageDownloads" ItemName="TargetingPackForPruneDataCollated" /> | ||
</CollatePackageDownloads> | ||
|
||
<!-- Can't run custom tasks in the build before NuGet restore, so create a separate project and restore that to download the packages --> |
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.
When is this run?
Improves how package pruning data is supplied in the .NET SDK.
Targeting packs include a PackageOverrides.txt which provides the data we can use to determine the packages that should be pruned. However, this data was not entirely accurate for previous versions of .NET, as it was meant as an optimization so it didn't matter much if a few packages were missing or the versions listed weren't up to date. As of .NET 10, that should be fixed, so we will use the PackageOverrides.txt data as the source for package pruning for .NET 10 and higher.
For earlier versions of .NET, and for .NET Standard and .NET Framework, we will use data that has been calculated based on running conflict resolution and curated to be correct. This data is encapsulated in the FrameworkPackages source files.
During the .NET SDK build, targeting packs are downloaded for previous versions of .NET that are version 10.0 or higher, and the PackageOverrides.txt files from those targeting packs are laid out in a PrunePackageData folder in the SDK layout. Since there aren't currently any "previous versions of .NET that are version 10.0 or higher", this won't actually do anything until .NET 11.
The GetPackagesToPrune task will load data from the FrameworkPackages, the PrunePackageData folder, or the targeting packs for the current version of .NET that are bundled with the SDK, depending on the target framework and version.