Skip to content

Enable full dotnet --info output in the AOT CLI - #55084

Merged
JeremyKuhne merged 1 commit into
dotnet:mainfrom
JeremyKuhne:aot-cli-dotnet-info
Jun 30, 2026
Merged

JeremyKuhne merged 1 commit into
dotnet:mainfrom
JeremyKuhne:aot-cli-dotnet-info

Conversation

@JeremyKuhne

@JeremyKuhne JeremyKuhne commented Jun 30, 2026 •

Copy link
Copy Markdown
Member

Summary

The AOT dotnet CLI (dotnet-aot) previously omitted the Workload version, MSBuild version, and the .NET workloads installed section from dotnet --info (they were gated behind #if !CLI_AOT). This enables all of them so the AOT --info output matches the managed CLI line-for-line.

Changes

  • MSBuild version — reference Microsoft.Build in the AOT closure so ILC compiles ProjectCollection.DisplayVersion. This path is AOT-clean (zero trim/AOT warnings).
  • Workload version + section — gate the eager workload installer (NuGet/MSI) out of WorkloadInfoHelper under #if CLI_AOT and build the installation-record repository directly, mirroring WorkloadInstallDetector. The full installer subsystem is therefore not compiled into the AOT binary; only the read-only reporting surface is.
  • Visual Studio workload detection (COM) — compiled into the AOT build, consuming the AOT-safe COM interop helpers (ComClassFactory, ComScope, BSTR, HRESULT, CLSID) from Microsoft.DotNet.Cli.Utils via InternalsVisibleTo. Gated on TARGET_WINDOWS.
  • NuGet System.Text.Json — select the STJ deserialization path in the AOT binary via the NuGet.UseSystemTextJsonDeserialization runtime host configuration option (Trim="true") so the reflection-based Newtonsoft.Json branch is trimmed.
  • Tests — updated the AOT --info tests to assert the now-included workload and MSBuild sections (including a non-empty value check on the MSBuild version line).

The shared files (ParserOptionActions.cs, WorkloadInfoHelper.cs, VisualStudioWorkloads.cs) use #if CLI_AOT so the managed CLI behavior is unchanged.

Validation

  • dotnet-aot NativeAOT publish (win-x64): 0 trim/AOT warnings.
  • AOT and managed --info output verified identical line-for-line (Compare-Object).
  • --info tests pass in-process and as a native AOT binary; full AotParserTests (42) pass; the managed dotnet.csproj builds clean.

Sample output (identical for AOT and managed):

.NET SDK:
 Version:           11.0.100-dev
 Commit:            N/A
 Workload version:  11.0.100-manifests.e3b0c442
 MSBuild version:   18.9.0-preview-26311-113+50e862b8d

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.26200
 OS Platform: Windows
 RID:         win-x64
 Base Path:   ...

.NET workloads installed:
There are no installed workloads to display.
Configured to use workload sets when installing new manifests.
No workload sets are installed. Run "dotnet workload restore" to install a workload set.

AOT size & startup impact

Measured with the aot-impact-analysis skill (win-x64). Size is isolated to this PR: PR side is the merged squash commit 3279708b, baseline is its parent 110f3d0c.

Size — native dotnet-aot.dll

Size
Base (110f3d0c) 17.668 MB
This PR (3279708b) 18.226 MB
Delta +571 KB (+3.15%)

Top real contributors all map to features this PR enables — nothing large maps to "nothing", so no sign of an unintended dependency in the AOT graph:

Grown Δ Maps to
System.Private.CoreLib +181.8 kB reflection/formatting for workload + MSBuild reporting
System.Linq +86.4 kB enumeration in WorkloadInfoHelper / workload set reporting
Microsoft.NET.Sdk.WorkloadManifestReader +67.2 kB workload version + .NET workloads installed section
System.Text.Json +40.9 kB NuGet STJ deserialization path (trims Newtonsoft branch)
Microsoft.Build.Framework +4.5 kB MSBuild version line
Microsoft.DotNet.Cli.Utils +1.4 kB AOT-safe COM interop for VS workload detection

Startup — managed vs AOT (same SDK build)

DOTNET_CLI_ENABLEAOT off = managed dotnet.dll (bridged in-process), on = native NativeEntryPoint. 15 iterations / 3 warmup, median wall-clock:

Command managed AOT Delta
dotnet --version 219.4 ms 21.0 ms -90.4% (~10x)
dotnet --info 371.5 ms 73.2 ms -80.3% (~5x)

The expanded --info from this PR is compiled natively into the AOT binary and still comes in ~5x faster than the managed equivalent. cli.runtime=aot + telemetry-setup/parse/invocation spans confirmed the AOT path was actually exercised (the info-gathering this PR added lives in the invocation span).

⚠️ Methodology note: perf runs must launch from outside the repo tree. The repo global.json sdk.paths: [".dotnet", "$host$"] makes the native muxer resolve the bootstrap .dotnet SDK (no dotnet-aot.dll) before the built redist, so from inside the repo the AOT path never fires and both legs run the same managed CLI. Setting DOTNET_ROOT/PATH alone does not override this.

win-x64 only; osx-arm64 (also in CI) not measured here.

The AOT CLI (dotnet-aot) previously omitted the workload version, MSBuild version, and the .NET workloads installed section from dotnet --info; they were gated behind #if !CLI_AOT. They now render in AOT and match the managed CLI output line-for-line.

MSBuild version: reference Microsoft.Build so ILC compiles ProjectCollection.DisplayVersion. The path is AOT-clean with no trim/AOT warnings.

Workload version and section: gate the eager workload installer (NuGet/MSI) out of WorkloadInfoHelper under #if CLI_AOT and build the installation-record repository directly (mirroring WorkloadInstallDetector), so the installer subsystem is not compiled into AOT. Visual Studio workload detection (COM) is compiled into AOT using the AOT-safe COM interop helpers in Microsoft.DotNet.Cli.Utils.

Select the NuGet System.Text.Json deserialization path in the AOT binary via the NuGet.UseSystemTextJsonDeserialization feature switch so the reflection-based Newtonsoft.Json path is trimmed away.

Update the AOT --info tests to assert the now-included workload and MSBuild sections.
Copilot AI review requested due to automatic review settings June 30, 2026 21:38

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.

Pull request overview

Enables the NativeAOT dotnet-aot CLI to emit the full dotnet --info output (matching the managed CLI), including workload version, MSBuild version, and the “.NET workloads installed” section, while keeping installer-heavy workload machinery out of the AOT closure.

Changes:

  • Print Workload/MSBuild version lines and the workloads section in the AOT --info path.
  • Refactor workload reporting to be AOT-friendly by constructing the installation-record repository directly under #if CLI_AOT, and gate installer-only code out.
  • Update AOT tests to assert the newly included --info sections (including a non-empty MSBuild version check).

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/dotnet-aot.Tests/AotParserTests.cs Updates --info tests to expect workload/MSBuild sections and validate MSBuild version is non-empty.
test/dotnet-aot.Tests/AotIntegrationTests.cs Updates integration test expectations for AOT --info output.
src/Cli/dotnet/ParserOptionActions.cs Enables printing workload/MSBuild info + workload listing for --info under CLI_AOT.
src/Cli/dotnet/Commands/Workload/WorkloadInfoHelper.cs Adds AOT-specific, read-only workload reporting construction (no installer) and adjusts interface implementation.
src/Cli/dotnet/Commands/Workload/List/VisualStudioWorkloads.cs Gates installer-dependent VS workload record-writing logic out of AOT builds.
src/Cli/dotnet-aot/dotnet-aot.csproj Forces NuGet to use STJ deserialization via runtime host config to avoid reflection-based JSON in AOT.
src/Cli/dotnet-aot/AotSourceFiles.props Adds Microsoft.Build runtime to the AOT closure and includes workload reporting sources (plus VS workload query on Windows).

Comment thread test/dotnet-aot.Tests/AotParserTests.cs Resolved
@baronfel

Copy link
Copy Markdown
Member

Love this! Would love perf and size analyses for this just to checkpoint each enhancement we make to the AOT space.

@baronfel baronfel added the Area-dotnet AOT Items that are part of the dotnet CLI AOT-ification effort label Jun 30, 2026
@baronfel baronfel modified the milestones: 11.0.1xx, 11.0-preview7 Jun 30, 2026
@JeremyKuhne

Copy link
Copy Markdown
Member Author

/aot-size

@JeremyKuhne
JeremyKuhne enabled auto-merge (squash) June 30, 2026 22:07
@JeremyKuhne
JeremyKuhne merged commit 3279708 into dotnet:main Jun 30, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-dotnet AOT Items that are part of the dotnet CLI AOT-ification effort

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants