Repository navigation
Track additional ReadyToRun compiler outputs for incremental builds - #57255
Merged
Merged
Conversation
Add AdditionalOutputs metadata to _ReadyToRunCompileList entries listing files crossgen2 writes besides OutputR2RImage and OutputPDBImage, and include it in the _CreateR2RImages Outputs. Composite entries list their rewritten component files, so a missing or stale component recompiles the composite image. Targets that change the set of files crossgen2 emits can update the metadata. Co-authored-by: Copilot <[email protected]>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
davidwrighton
requested review from
jtschuster,
maraf and
sbomer
and
a balanced review from Copilot
November 20, 2026 19:50
davidwrighton
marked this pull request as ready for review
November 20, 2026 19:51
sbomer
approved these changes
Nov 20, 2026
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
When composite roots are configured, unrooted assembly changes can leave stale published components, and incremental tests for those changes and overridden outputs are missing.
2 open issues
What changed in this PR
This PR extends the SDK’s ReadyToRun output tracking so missing or outdated composite component files can trigger recompilation. It also provides an extension point for the browser component bundle planned in dotnet/runtime#137713.
Changes:
- Adds
AdditionalOutputsmetadata to compiler planning and MSBuild incremental output checks. - Derives composite output paths from the files already selected for publishing.
- Adds task-level metadata assertions and a publish regression test for a deleted component.
| File | Description |
|---|---|
test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishReadyToRun.cs |
Tests recompilation after deleting a composite component. |
test/Microsoft.NET.Build.Tasks.Tests/GivenAPrepareForReadyToRunCompilation.cs |
Checks additional output paths for Mach-O and WebAssembly composites. |
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.CrossGen.targets |
Tracks additional compiler outputs and documents metadata overrides. |
src/Tasks/Microsoft.NET.Build.Tasks/PrepareForReadyToRunCompilation.cs |
Populates composite entries with component output paths. |
src/Tasks/Common/MetadataKeys.cs |
Defines the AdditionalOutputs metadata key. |
Review effort: Balanced
davidwrighton
temporarily deployed
to
copilot-pat-pool
November 23, 2026 18:11 — with
GitHub Actions
Inactive
davidwrighton
temporarily deployed
to
copilot-pat-pool
November 23, 2026 18:11 — with
GitHub Actions
Inactive
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
_CreateR2RImagescurrently lists onlyOutputR2RImageandOutputPDBImageas outputs. A composite compilation also writes one rewritten component file per input (PE/Mach-O component assemblies, or.wasmcomponent stubs). If one of those files is deleted or becomes stale, the target is still considered up to date. Publish then fails, or it copies an outdated component.This PR adds an
AdditionalOutputsmetadata contract to_ReadyToRunCompileList:AdditionalOutputsis a semicolon-separated list of files the compiler produces besidesOutputR2RImageandOutputPDBImage._CreateR2RImagesnow usesOutputs="%(OutputR2RImage);%(OutputPDBImage);%(AdditionalOutputs)". Batching splits the list, so incrementality stays per entry: deleting or aging a single extra output recompiles only that entry.PrepareForReadyToRunCompilationfills it in for the composite entry from the same component paths it already uses to buildReadyToRunFilesToPublish, so the outputs and the published files come from one source of truth._PrepareForReadyToRunCompilation. Planned crossgen2 output-layout changes then only need a metadata update in the task or in the extending targets, not a new target or a workaround. For example:Motivation
dotnet/runtime#137713 makes crossgen2 bundle composite WebCIL components into a single
<app>.components.wasmfile for browser CoreCLR. That file was not a tracked output, so the runtime targets temporarily deleted the composite owner image to force a recompile when the bundle was missing. That workaround has now been removed; this PR models the extra output directly. The review comment at dotnet/runtime#137713 (comment) asked for the output to be modeled properly in the SDK instead.Merge sequencing
src/tasks/Crossgen2Tasks, which must stay equivalent to the SDK copy, and setAdditionalOutputsto the bundle path inBrowser.CoreCLR.targets. Remove the owner-image invalidation workaround. These runtime changes do not need to wait for the SDK version to flow into runtime'sglobal.json: the in-tree path uses the shim.AdditionalOutputs. Until then, that opt-in path will not rebuild solely because a bundle is missing; the bundle has not shipped, so this temporary gap is accepted. Do not retain or restore the owner-deletion workaround for this transition.No capability flag is needed. Older SDKs ignore
AdditionalOutputs; newer SDKs use it for incremental tracking.Validation
./build.sh: succeeded../.dotnet/dotnet scripts/RunTests.cs -- --project test/Microsoft.NET.Build.Tasks.Tests/Microsoft.NET.Build.Tasks.Tests.csproj --filter "FullyQualifiedName~GivenAPrepareForReadyToRunCompilation": passed, 5/5. This includes newAdditionalOutputsassertions for Mach-O and wasm composite planning../.dotnet/dotnet scripts/RunTests.cs -- --project test/Microsoft.NET.Publish.Tests/Microsoft.NET.Publish.Tests.csproj --filter "FullyQualifiedName~It_recompiles_composite_image_when_a_component_output_is_missing|FullyQualifiedName~It_recompiles_readytorun_images_when_crossgen2_arguments_change|FullyQualifiedName~It_can_publish_readytorun_composite_with_subdirectory_relative_path": passed, 3/3. The new test deletes a composite component and confirms the next publish recompiles it.The suite ran before a final cleanup that removed only an unused private property; it was not re-run after that change. The new publish test has not been confirmed to fail without the target change.
Note
This PR description was drafted with GitHub Copilot.