Repository navigation
[release/11.0.1xx] Make optimized Native AOT publish opt-in - #56661
Merged
marcpopMSFT merged 2 commits intoOct 21, 2026
Merged
marcpopMSFT merged 2 commits into
marcpopMSFT merged 2 commits into
Conversation
Preserve full Build behavior by default on release/11.0.1xx while retaining explicit optimized publish opt-in. Cover default, opt-in, opt-out, and NoBuild behavior and update the publish optimization documentation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c9ecf349-4066-472e-8109-aef69850e2f9
|
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.
🟢 Approval recommended
The narrow default change preserves existing alternatives, has focused regression coverage, and has no unresolved findings.
0 open findings
What changed in this PR
Makes optimized Native AOT publishing opt-in for .NET 11, restoring full Build behavior by default while compatibility fixes remain separate.
Changes:
- Defaults
UseOptimizedPublishtofalse, preserving explicit opt-in andNoBuildbehavior. - Expands regression coverage for property combinations, build hooks, outputs, and native execution.
- Documents the opt-in behavior.
| File | Description |
|---|---|
| test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAnAotApp.cs | Covers default, override, and no-build scenarios. |
| src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets | Disables optimized AOT publishing by default. |
| documentation/general/publish-build-optimization.md | Explains .NET 11 opt-in behavior. |
🧠 Review effort: Balanced
baronfel
approved these changes
Oct 15, 2026
Member
Author
|
/tactics |
…rage Explicitly opt the optimized target-chain and cleanup tests into the optimized pipeline. Preserve XML documentation coverage across default, opt-in, and no-build publish cases, and align the target-chain guard and documentation with the merged fixes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ba7627dd-f614-44fb-894e-0b22159af3d4
marcpopMSFT
enabled auto-merge
October 21, 2026 16:45
joeloff
approved these changes
Oct 21, 2026
marcpopMSFT
requested a deployment
to
copilot-pat-pool
October 21, 2026 17:59 — with
GitHub Actions
Waiting
This branch is waiting to be 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.
🤖 Disable the default rollout of optimized Native AOT publish in .NET 11 while compatibility issues are addressed.
Changes
UseOptimizedPublishtofalsefor Native AOT publish, restoring fullBuildexecution and build hooks unless explicitly opted in.UseOptimizedPublish=trueopt-in, the non-AOT guard, andNoBuildbehavior.NoBuild; assert build hooks, managed build outputs, and runnable native publish output. Keep the optimized project-reference test explicitly opted in.This is an independent change based on
release/11.0.1xx, not stacked on #56650. It does not changemain, schedule .NET 12 activation, or incorporate #56620, #56649, or #56650.Related customer reports: #56618 and #56645. This defers the default rollout rather than replacing the fixes needed for explicit opt-in.
Validation
build.cmd -skipCrossgen -skipInstallers.Microsoft.NET.Publish.Tests: 9 passed, including all six default/false/true × build/no-build cases, optimized project references, unsupported publish modes, and the CoreBuild target-chain guard.TrimmingOptions_are_defaulted_correctly_on_trimmed_apps, 7 passed.artifacts/log/targeted-tests/.Validation was on Windows x64; the full test suite was not run. The redist build succeeded with existing unrelated NU1902/NU1903 warnings for
System.Security.Cryptography.Pkcs8.0.1 in ApiCompat projects; focused test builds had no warnings.Tactics
Summary
Optimized Native AOT publish (
UseOptimizedPublish, introduced in #54515) skips parts of the normalBuildtarget chain, which breaks build hooks and resource/doc-file handling for AOT apps (#56618, #56645). This PR changes the default inMicrosoft.NET.Publish.targetssoUseOptimizedPublishisfalsefor Native AOT publish, restoring fullBuildunless explicitly opted in. The explicit opt-in, non-AOT guard andNoBuildbehavior are retained, and docs are updated. Deferring the default is a small, low-blast-radius change suited to servicing; fixes for opt-in remain separate.Customer Impact
Native AOT publish in .NET 11 pre-release SDKs can fail (e.g. MSB3030 for the XML documentation file when
GenerateDocumentationFileis true, #56618) or skipBeforeTargets="ResolveReferences"resource targets (#56645). Affects Native AOT publish scenarios by default. Workaround: setUseOptimizedPublish=false. This change makes that the default.Regression?
Yes, introduced in #54515 (optimized AOT publish enabled by default).
Testing
GivenThatWeWantToPublishAnAotApp.cscover unset/false/true × build/no-build, asserting build hooks, managed build outputs and runnable native output; project-reference test explicitly opts in.Microsoft.NET.Publish.Tests(9 passed) and ILLink scope test (7 passed) on Windows x64 with a fresh redist SDK build.Risk
Low. Three files changed (+83/-26): a two-line default change in targets, tests and docs. It reverts to the long-standing full
Buildbehavior; users who explicitly opt in are unaffected.