Skip to content

[release/11.0.1xx] Make optimized Native AOT publish opt-in - #56661

Merged
marcpopMSFT merged 2 commits into
dotnet:release/11.0.1xxfrom
marcpopMSFT:marcpopmsft-disable-optimized-publish-default
Oct 21, 2026
Merged

marcpopMSFT merged 2 commits into
dotnet:release/11.0.1xxfrom
marcpopMSFT:marcpopmsft-disable-optimized-publish-default

Conversation

@marcpopMSFT

@marcpopMSFT marcpopMSFT commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

🤖 Disable the default rollout of optimized Native AOT publish in .NET 11 while compatibility issues are addressed.

Changes

  • Default UseOptimizedPublish to false for Native AOT publish, restoring full Build execution and build hooks unless explicitly opted in.
  • Retain UseOptimizedPublish=true opt-in, the non-AOT guard, and NoBuild behavior.
  • Cover unset, explicit false, and explicit true values with and without NoBuild; assert build hooks, managed build outputs, and runnable native publish output. Keep the optimized project-reference test explicitly opted in.
  • Update the optimization documentation to describe the .NET 11 opt-in behavior.

This is an independent change based on release/11.0.1xx, not stacked on #56650. It does not change main, 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

  • Built a fresh isolated Debug redist SDK with build.cmd -skipCrossgen -skipInstallers.
  • Targeted 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.
  • Configured ILLink scope: TrimmingOptions_are_defaulted_correctly_on_trimmed_apps, 7 passed.
  • Targeted runs retained TRX results and build binlogs under 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.Pkcs 8.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 normal Build target chain, which breaks build hooks and resource/doc-file handling for AOT apps (#56618, #56645). This PR changes the default in Microsoft.NET.Publish.targets so UseOptimizedPublish is false for Native AOT publish, restoring full Build unless explicitly opted in. The explicit opt-in, non-AOT guard and NoBuild behavior 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 GenerateDocumentationFile is true, #56618) or skip BeforeTargets="ResolveReferences" resource targets (#56645). Affects Native AOT publish scenarios by default. Workaround: set UseOptimizedPublish=false. This change makes that the default.

Regression?

Yes, introduced in #54515 (optimized AOT publish enabled by default).

Testing

  • Unit/integration tests in GivenThatWeWantToPublishAnAotApp.cs cover unset/false/true × build/no-build, asserting build hooks, managed build outputs and runnable native output; project-reference test explicitly opts in.
  • Author reports targeted Microsoft.NET.Publish.Tests (9 passed) and ILLink scope test (7 passed) on Windows x64 with a fresh redist SDK build.
  • Full suite not run locally; PR CI pipelines were started. Approved by baronfel.

Risk

Low. Three files changed (+83/-26): a two-line default change in targets, tests and docs. It reverts to the long-standing full Build behavior; users who explicitly opt in are unaffected.

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
Copilot AI balanced review requested due to automatic review settings October 15, 2026 20:18
@marcpopMSFT
marcpopMSFT requested review from a team as code owners October 15, 2026 20:18
@azure-pipelines

Copy link
Copy Markdown
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 UseOptimizedPublish to false, preserving explicit opt-in and NoBuild behavior.
  • 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

@marcpopMSFT

Copy link
Copy Markdown
Member Author

/tactics

@rbhanda rbhanda added this to the 11.0.0 milestone Oct 19, 2026
…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
marcpopMSFT enabled auto-merge October 21, 2026 16:45
@marcpopMSFT
marcpopMSFT merged commit 4ca6818 into dotnet:release/11.0.1xx Oct 21, 2026
23 checks passed

This branch is waiting to be deployed

1 waiting deployment
copilot-pat-pool — 72f42609 Waiting Oct 21, 2026 by marcpopMSFT via pre_activation #9909
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants