-
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
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. |
b13c6e7
to
6ea8a4e
Compare
@dotnet/product-construction @baronfel Can someone take a look at this VMR build issue? Is it a known issue showing up elsewhere? Thanks. |
Someone once said to me that "the SDK cannot build the SDK" and I did not initially understand what was meant by that simple but provocative statement. It has stuck with me. |
@dotnet/product-construction @dotnet/source-build Ping on this, can someone take a look at why the source build / VMR builds here are failing? |
It's not a known issue. Somehow these changes are causing the |
Thanks, it turned out this was my mistake but it was in the generation of the bundled versions file which currently isn't applied for our normal test runs. |
1d61a0c
to
79c145a
Compare
@ViktorHofer @ericstj I've updated this so that you can set a Would this work for you? It essentially allows you to specify multiple targeting pack roots just for the purposes of looking up the PackageOverrides.txt file to get the prune package data. You'll still have to have the full folder layout, so under the root you'd need the package contents to be under something like |
@dsplaisted I assume we can't depend on the That target probably doesn't run during restore but I still wanted to ask. |
@mthalman @dotnet/product-construction This is failing for the VMR build in the aspnetcore build.repotasks build. It's failing in new code I'm adding in this PR, and it looks like it's failing because the targeting packs aren't included in the layout of the SDK it's using. Do we expect the targeting packs to be in the packs directory for the SDK that's being used here? Is there a way to see the source build layout? I don't seem to see it in the build artifacts. |
Yes, |
The build that's failing is the stage 2 source build leg. In that same pipeline, the leg that's passing is stage 1. In stage 1, we use the Microsoft-built SDK to build the VMR in source build mode. In stage 2, we take the SDK produced by stage 1 and build the VMR again using that SDK. This verifies that the source-built SDK can be used to build the VMR. So the issue seems to be with how the SDK layout is produced by stage 1. You can find that SDK in the pipeline artifacts: |
…ing packages for them
This partially reverts commit c0bfcdb. # Conflicts: # src/Installer/redist-installer/targets/BundledTemplates.targets
Co-authored-by: Michael Yanni <MiYanni@microsoft.com>
This will support repos that are building a targeting pack and then using it in their build
Also fix some tests
@mthalman Thanks, that's helpful. I looked in the stage 1 layout, and there is a
Should the |
…rty to allow missing data
1be85fd
to
ac0bf12
Compare
Something points to the wrong location. What is that? |
<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.
This worries me. I submitted various PRs in the last month that removed these in-built restores. That has multiple downsides:
- The build doesn't work without network connection after an initial
build.cmd/sh -restore
. "Air plane mode" - With a coming SFI requirement, the times when we can hit the network will be restricted.
- Increased complexity and the build is slower because of the intermediate projects.
We hit that same limitation in SBRP (https://github.com/dotnet/source-build-reference-packages/blob/232bcf31aad21949f80d6706720540b85e43fff3/src/packageSourceGenerator/PackageSourceGenerator.proj#L98C9-L104) and decided to introduce an inline task that can run before restore.
Now that I see this additional use-case, I would prefer if we move the CollatePackageDownloads
task into the Arcade SDK which makes it available before project restore and solves this recurring problem for our own repositories (SBRP, SDK and potentially others).
FWIW I'm not sure why NuGet requires customers to collate the items in the first place. Why can't NuGet parse such items:
<PackageDownload Include="x" Version="[7.0.0]" />
<PackageDownload Include="x" Version="[8.0.0]" />
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.
It's not just the collating, there's also the GeneratePackagePruneDataDownloads
task.
It would be nice if we can find a good pattern for running custom tasks that help determine what needs to be restored.
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.
Right. Looking at the GeneratePackagePruneDataDownloads
task, I don't think that needs to be a build task at all. It should be able to express what the task is doing in pure msbuild syntax with even less code with item batching.
Yes that will work to repos that build live targeting pakcs. Thanks for responding to my feedback. Just curious, why is that a property instead of an item? |
// HOWEVER: we don't download the targeting pack for the maximum .NET version here, as we may still be in preview. | ||
// Rather, the GetPackagesToPrune task will load the package prune data for the current version from the | ||
// targeting packs that ship with the SDK. | ||
for (int netVersion = 10; netVersion < maxNetVersion; netVersion++) |
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 a no-op today with .NET 10 as netVersion
is equal to maxNetVersion
?
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.
I just looked over the files that changed since the last time I reviewed. Looks good!
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.