Executive Summary
Chet Husk details the engineering journey of transforming the .NET CLI into a Native AOT (Ahead-of-Time) binary in .NET 11. With billions of CLI invocations executed every month worldwide by human developers, CI/CD pipelines, and autonomous AI agents, shaving tens to hundreds of milliseconds off standard commands produces massive cumulative throughput and cost savings.
Headline Accomplishments:
- Measured Performance Wins: Core commands like
dotnet --versionrun two-thirds faster (cutting80 ms);100 ms** per invocation. Chained command sequences compound these savings dramatically.dotnet tool listand tool invocations cut ** - Dual-Engine Architecture (Muxer + Native AOT Library): The CLI is not a standalone executable, but a native AOT library loaded by the native .NET muxer via a C ABI entrypoint. Supported commands run purely AOT; unsupported commands gracefully fall back to CoreCLR via
hostfxr("Strangler Fig" architecture). - Architectural Disciplines & SDK Root: Moving to Native AOT forced the team to eliminate fragile patterns like
Assembly.Locationand resolve unversioned vs. versioned SDK root directory ambiguities with dedicated domain abstractions. - Binary Bloat Mitigation & "Size of Spy": Analyzing trimmer call graphs to eliminate "dominator" subgraphs (e.g. replacing a 5 MB BCL
XmlReaderdependency tree with a lightweight recursive-descent parser). - Major SDK Packaging Win: Through symlink deduplication in tarballs and zips by Michael Simons, the .NET 11 SDK eliminated 53 MB compressed / 150 MB uncompressed (Linux x64) of redundant binaries, leaving overall SDK payloads and container images smaller despite adding native AOT binaries.
- Testing Native AOT at Scale: Creating the internal
DNtest harness to emulate muxer C-ABI invocations and enforce strict behavioral parity between AOT and managed execution paths.
Detailed Section-by-Section Breakdown
1. Global Scale of the .NET CLI & The 100ms Opportunity
Presenter: Chet Husk
The .NET ecosystem runs on dotnet. With global telemetry recording billions of command executions every month across developer terminals, agentic loops, and CI runners:
- Saving 80–100 milliseconds per command eliminates thousands of aggregate hours of developer wait time.
- Diagnostic commands like
dotnet --versiondrop from ~120 ms to ~40 ms (a 66% latency reduction). - Tool listings (
dotnet tool list) cut ~100 ms. - Tool execution (both global and local .NET tools) drops invocation overhead by another 100 ms.


2. Chained Execution & The AI Agent Multiplier
While individual 80 ms savings feel subtle during casual typing, modern workflows chain dozens of CLI operations. In automated environments (e.g., CI matrix builds or autonomous AI agents iterating through build, test, package, and tool validation loops), the reduced overhead compounds exponentially.

3. Native AOT Command Coverage: Today vs. Future Roadmap
In .NET 11, the native AOT execution bubble covers:
- Diagnostic Commands:
dotnet --version,dotnet --list-sdks,dotnet --list-runtimes. - Solution Management:
dotnet slncommands (add, remove, list). - Tool Management & Execution: Listing, running, removing, and searching global/local tools; built-in subcommands like
user-secrets. - Cached File-Based Applications: Second-run cached executions of
.csscript files bypass JIT compilation and launch via AOT. - MTP Testing: Running Microsoft Testing Platform (MTP) tests with
--no-buildutilizes the native AOT path.
Future Roadmap:
- Compiling MSBuild project evaluation into the AOT bubble.
- Tool installation and restore (pending NuGet AOT JSON serialization).
- The
.NET newtemplating engine.

4. Architecture: The Muxer and the Native AOT Library
Chet revealed that the .NET CLI is not an AOT executable; it is a Native AOT shared library:
[ dotnet CLI Invocation ]
│
▼
[ .NET Muxer ] (Native executable: dotnet.exe / dotnet)
│
├──> 1. Resolves SDK version directory (e.g. sdk/11.0.100)
│
├──> 2. Discovers Native AOT CLI library
│ │
│ ▼
│ Calls exported C ABI entrypoint: execute_cli()
│ │
│ ├── [Is command in AOT Bubble?]
│ │ │
│ │ ├── YES ──> Runs purely Native AOT (Zero JIT, ~40ms)
│ │ │
│ │ └── NO ──> Invokes hostfxr resolver
│ │ │
│ ▼ ▼
└──────────────────────────> Starts CoreCLR & executes managed CLI DLL
This hybrid approach allows .NET 11 to deliver instant native startup for supported commands while preserving 100% backward compatibility for complex legacy tasks through managed fallback.

5. Architectural Disciplines: The SDK Root Hurdle
Building a native AOT library highlighted several architectural assumptions embedded in the codebase:
- Fragile Reflection: Code relying on
Assembly.GetExecutingAssembly().Locationfailed because native AOT binaries strip or nullify assembly file paths. - Ambiguous Directories: In managed execution,
AppContext.BaseDirectorypoints to the specific SDK version folder (dotnet/sdk/11.0.100/). In a native AOT library hosted by the muxer, it resolved to the parent unversioned directory (dotnet/). - Domain Clarification: The team had to formalize an explicit
SdkRootdomain abstraction with hosting-aware locator strategies, ensuring clean separation between CoreCLR and native execution contexts.

6. Pushing the Ecosystem: NuGet & MSBuild AOT Enablement
Because the CLI aggregates key .NET dependencies, the CLI team served as a catalyst for other teams:
- NuGet: Partnered to eliminate reflection in package management JSON parsers, unblocking AOT tool installation.
- MSBuild: Prototyping AOT MSBuild project file evaluation, opening the door for external tools and third-party CLIs to run fast evaluation without full runtime spin-up.

7. The Size Tradeoff & Binary Bloat Analysis
Bringing commands into the AOT bubble increases disk footprint:
- Initial CLI command parsing added ~5 MB.
- Tool execution logic added ~2 MB.
To evaluate these tradeoffs on pull requests, the team created automated PR size-diff gates and tools:
- Size of Scope: IL trimmer reachability analyzer.
- Size of Spy: Developed by Chet Husk to parse trimmer DGML dependency graphs and uncover "dominators" (isolated methods/classes that pull in massive downstream dependency subgraphs).
The XML Reader Dominator Case Study:
Parsing XML files initially dragged in the full BCL XmlReader. XmlReader supports XML Schemas (XSDs), which references network URI resolvers, which pulled in HTTP and cryptography libraries—adding 5 MB of binary bloat! By replacing it with a small, purpose-built recursive-descent parser, the team saved over 5 MB across every supported RID.


8. SDK Deduplication: Reclaiming 150 MB with Symlinks
To offset the size of the new AOT binaries, Michael Simons investigated redundancy in the overall .NET SDK packaging:
- Identified dozens of duplicate managed assemblies across runtime packs and SDK directories.
- Leveraged tarball symlink support and content-based deduplication during packaging.
- Results:
- Removed 53 MB of compressed archive payload.
- Eliminated ~150 MB of uncompressed disk space on Linux x64.
- This net reduction easily absorbed the 15–20 MB native AOT libraries, leaving .NET 11 SDK container images smaller overall than .NET 10!

9. Verification & Parity Testing (DN Test Harness)
To guarantee flawless compatibility between the managed CLI and the native AOT library:
- Standard unit tests failed to replicate the exact native muxer loading environment.
- The team built
DN, an internal test harness that simulates the native muxer’s C ABI invocation. - Parity tests execute test suites against both managed and AOT modes to verify identical console outputs, exit codes, and diagnostic streams.