Skip to content

Enable MSBuild-backed commands in the Native AOT CLI#55441

Draft
baronfel wants to merge 13 commits into
mainfrom
baronfel-aot-msbuild-evaluation
Draft

Enable MSBuild-backed commands in the Native AOT CLI#55441
baronfel wants to merge 13 commits into
mainfrom
baronfel-aot-msbuild-evaluation

Conversation

@baronfel

@baronfel baronfel commented Jul 23, 2026

Copy link
Copy Markdown
Member

I highly suggest reviewing this commit-by-commit. Most of the actual work is in the first few commits, laying the infrastructure and enabling more CLI feature areas to build under NAOT (workload updates, MSbuild evaluation, etc). Then the actual command enablements are almost trivial by comparison.

Summary

  • Register the workload and NuGet MSBuild SDK resolvers through MSBuild's static resolver APIs and centralize versioned SDK path resolution.
  • Evaluate physical projects and directive-free virtual projects in Native AOT. File-based apps that use directives are currently blocked by Fix IL3000: guard Assembly.Location access behind RuntimeFeature.IsDynamicCodeSupported roslyn#84599
  • Route pack, publish, build, restore, clean, and msbuild through the Native AOT CLI while continuing to execute MSBuild out of process.
  • Include workload advertising-manifest and SDK vulnerability refresh support in the AOT closure, using shared lightweight manifest installers and leaving RestoringCommand unchanged from main.
  • Preserve managed fallback for unsupported inputs such as .nuspec packing and directive-bearing file-based apps.

Validation

  • Managed dotnet-aot, managed dotnet, and shipping Native AOT publication succeed.
  • 14 focused Native AOT MSBuild evaluation tests pass.
  • 8 workload/vulnerability tests pass in both Native AOT and managed execution.
  • Command routing, output parity, resolver registration, SDK-root forwarding, physical projects, and virtual projects are covered.

Size and performance

The same-toolchain Debug Native AOT image grows from 34,438,656 to 73,207,808 bytes: +38,769,152 bytes (+36.97 MiB, +112.6%). Nearly all of that increase comes from the initial MSBuild/NuGet evaluation closure (details at NuGet/Home#14846 (comment)); workload updates add about 1.44 MB and the later command migrations add less than 100 KiB combined.

Command Clean/full Incremental/no-op
pack 1.6% faster 10.8% faster
publish 1.6% slower 2.8% slower
build 4.3% faster 11.1% faster
restore 8.2% faster 10.7% faster
clean 10.8% faster 13.0% faster
msbuild 3.5% faster 8.3% faster

Top-level CLI CPU falls by roughly 80-99%, and peak working set falls by 69-88%. Actual MSBuild execution remains in a child process, so these resource reductions represent CLI hosting and JIT overhead rather than the complete process tree.

baronfel added 13 commits July 23, 2026 15:15
Route MSBuild forwarding and workload resolver probes through SdkPaths so managed and Native AOT hosts consistently resolve the selected versioned SDK directory.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 54c93774-3a89-47a1-a53a-14dbdd71a0c8
Register workload and NuGet resolvers before evaluation, include the trim-safe MSBuild and NuGet dependencies, and exercise stock SDK resolution in the Native AOT test layout.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 54c93774-3a89-47a1-a53a-14dbdd71a0c8
Compile the existing MsbuildProject and completion paths into the Native AOT CLI so command completions can evaluate configurations and target frameworks from the current project.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 54c93774-3a89-47a1-a53a-14dbdd71a0c8
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 54c93774-3a89-47a1-a53a-14dbdd71a0c8
Add the shared workload advertising, NuGet download and signing, MSI extraction, and SDK vulnerability services to the Native AOT closure. Cover the closure directly so restoring commands can use the unchanged shared RestoringCommand as they are enabled.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 54c93774-3a89-47a1-a53a-14dbdd71a0c8
Wire the pack action into the Native AOT parser, evaluate PackRelease in process, and forward restore and Pack to the selected SDK while preserving managed fallback for unsupported inputs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 54c93774-3a89-47a1-a53a-14dbdd71a0c8
Reuse the existing virtual project writer for evaluation-only file inputs, fall back for Roslyn directives and execution, and share entry-point validation with the managed CLI.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 54c93774-3a89-47a1-a53a-14dbdd71a0c8
Describe static SDK resolver registration, versioned SDK path requirements, physical pack behavior, directive-free virtual evaluation, workload maintenance parity, and managed fallback boundaries.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 54c93774-3a89-47a1-a53a-14dbdd71a0c8
Reuse the physical MSBuild command path for publish, evaluate PublishRelease in process, preserve managed fallback for file-based execution, and cover the native parser and forwarding behavior.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 54c93774-3a89-47a1-a53a-14dbdd71a0c8
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 54c93774-3a89-47a1-a53a-14dbdd71a0c8
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 54c93774-3a89-47a1-a53a-14dbdd71a0c8
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 54c93774-3a89-47a1-a53a-14dbdd71a0c8
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 54c93774-3a89-47a1-a53a-14dbdd71a0c8
@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant