Skip to content

[Breaking change]: .NET SDK will skip full build for AOT publish #55769

Description

@marcpopMSFT

Description

The .NET 11 SDK will no longer do a full build during AOT publish but rather only build the minimum needed to produce the AOT compiled output.

Version

.NET 11 RC 2

Previous behavior

When publishing with PublishAot=true, the full MSBuild Build target was executing as part of the publish pipeline, producing a complete self-contained managed deployment (apphost, DLLs, deps.json, runtimeconfig.json, and runtime pack files) in the output (bin\) directory. These artifacts are entirely unused by the AOT pipeline, which reads from @(IntermediateAssembly) in obj\, not from bin\.

New behavior

This change introduces a new _PublishOptimizedBuild target that runs only Compile (plus resource and satellite assembly targets) instead of the full Build for AOT publish, eliminating the confusing managed artifacts from the output directory while preserving all AOT publish functionality. A public opt-out property UseOptimizedPublish is provided for projects that rely on Build extensibility points (e.g., BeforeBuild, AfterBuild, BeforeTargets/AfterTargets="Build") or packages like Microsoft.Extensions.ApiDescription.Server. This fix is scoped to AOT-only in .NET 11 to minimize risk; expansion to other publish modes is planned for .NET 12 early previews (tracked in dotnet/sdk#55911).

Type of breaking change

  • Binary incompatible: Existing binaries might encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
  • Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code might require source changes to compile successfully.
  • Behavioral change: Existing binaries might behave differently at run time.

Reason for change

Reduce customer confusion on which binaries to use and save on AOT publish time. Now there should only be binaries in the publish folder.

Recommended action

Customers who have msbuild logic during AOT publish that depends on the full build could change to depend on publish targets instead.

Customers can opt-out into the old behavior by setting UseOptimizedPublish=false.

Feature area

SDK

Affected APIs

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions