Repository navigation
Restore validation, cleanup, and tool shims for optimized Native AOT publish - #56650
Merged
marcpopMSFT merged 5 commits intoOct 20, 2026
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 2 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Shared cleanup changes have unresolved XML and shim compatibility issues and require human review.
2 open findings
What changed in this PR
Restores validation, cleanup bookkeeping, and explicitly requested tool shims in the SDK’s optimized Native AOT publish pipeline.
Changes:
- Runs configuration validation before optimized build prerequisites.
- Records generated files and cleans obsolete tracked outputs.
- Adds shim generation, regression tests, and documentation.
| File | Description |
|---|---|
| test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAToolProjectWithPackagedShim.cs | Tests tool shim publishing modes. |
| test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAnAotApp.cs | Tests validation and cleanup scenarios. |
| src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets | Restores validation and cleanup bookkeeping. |
| src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackTool.targets | Registers optimized shim generation. |
| documentation/general/publish-build-optimization.md | Documents restored build contracts. |
🧠 Review effort: Balanced
Use one framework-based shim directory independent of inferred SelfContained, and include it in the generation cache. Cover optimized/full publish to NoBuild, build to optimized publish, custom staging roots, and self-contained managed tools. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
baronfel
approved these changes
Oct 15, 2026
Member
Author
|
/tactics |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 091747d8-06d9-4830-a9b2-aa50cb71eaa4
marcpopMSFT
enabled auto-merge
October 19, 2026 18:23
joeloff
approved these changes
Oct 20, 2026
marcpopMSFT
had a problem deploying
to
copilot-pat-pool
October 20, 2026 17:17 — with
GitHub Actions
Failure
This was referenced Oct 21, 2026
This branch had an error being 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.


🤖 Restore three build contracts skipped by optimized Native AOT publishing, in three separate commits.
Changes
_CheckForInvalidConfigurationAndPlatformbefore the optimized build prerequisites, restoring hooked SDK validations such as the runtime identifier/platform mismatch diagnostic (NETSDK1032)._BuildForOptimizedPublish, runIncrementalCleanbefore publish post-processing, and use_CleanRecordFileWriteson build failure. This restores intermediate DLL/PDB/XML/generated-file cleanup and removes obsolete tracked managed outputs after a prior full build without restoring managed build copies. This does not add cleanup tracking for every native or publish artifact.GenerateShimsAssetsonly when explicit tool shim runtime identifiers are requested, before cleanup and publish file collection. Preserve existing full-build andNoBuildshim behavior.Each commit includes regression coverage and updates to
documentation/general/publish-build-optimization.md.Validation
Microsoft.NET.Publish.Testscases: platform validation, successful and repeated publish cleanup, prior full build followed by optimized publish, failure before/after compilation followed by clean, optimized/full/no-build tool shims, no requested shims, managed tool shim compatibility, optimized output layout, the CoreBuild dependency guard, and unsupported optimized publish modes.Microsoft.NET.ILLink.Testssmoke cases selected from the configured ILLink scope.artifacts/log/targeted-tests/. Validation was on Windows x64; Linux/macOS were not run locally. The full SDK build succeeded with existing NU1902/NU1903 audit warnings forSystem.Security.Cryptography.Pkcs8.0.1 in ApiCompat projects; those dependencies were not changed or suppressed by this PR.Scope and related fixes
Targets
release/11.0.1xxfrom its provisioned baseline. This PR neither modifies nor includes the XML documentation repair in #56620 (for #56618), or the build-hook ordering repair in #56649 (for #56645). XML cleanup coverage disables publishing documentation so it tests compiler-output tracking independently of #56620.NoBuildremains a separate publish path.Tactics
Summary
Optimized Native AOT publish skipped the full build pipeline and so lost three build contracts: SDK configuration/platform validation (e.g. NETSDK1032), intermediate-output cleanup bookkeeping (
IncrementalClean), and tool shim generation. This PR runs_CheckForInvalidConfigurationAndPlatformfirst, wraps the optimized prerequisites in_BuildForOptimizedPublishwithIncrementalClean/_CleanRecordFileWrites, and addsGenerateShimsAssetsto the PackTool optimized pipeline only when explicit shim RIDs are requested. Changes are confined to Publish/PackTool targets, restoring previously expected behavior, which suits servicing.Customer Impact
Customers using optimized Native AOT publish on the 11.0 SDK (RC1 verified) can see missing validation errors (e.g. RID/platform mismatch no longer reported), stale intermediate or obsolete managed outputs after a prior full build, and missing packaged tool shims when shim runtime identifiers are requested. This affects specific scenarios (AOT publish, AOT tools with shims), not all users. No workaround is documented in the PR.
Regression?
Yes. The behavior was lost by the optimized publish build pipeline in the 11.0 SDK (reproduced with the installed 11.0 RC1 SDK). The specific introducing PR is not identified in the PR context.
Testing
GivenThatWeWantToPublishAnAotApp.csandGivenThatWeWantToPublishAToolProjectWithPackagedShim.cs, one set per commit.Risk
Low–Medium. About 240 lines changed, mostly tests and docs; target changes are ~19 lines across two shared targets files. The cleanup change touches shared incremental-clean behavior and shim staging paths, which carry some edge-case risk, but they apply only to the optimized publish path and are covered by focused tests.