Native AOT Compilation
Enable Native AOT in a .NET project, understand trim analysis, and publish a self-contained native binary.
What Is Native AOT?
Native Ahead-of-Time (AOT) compilation compiles your .NET app into a self-contained native binary at publish time. There is no JIT compiler, no .NET runtime needed on the target — just a single executable.
When to Use Native AOT
Native AOT shines for microservices, CLI tools, and serverless functions where startup time and memory footprint matter. It is not ideal for apps that rely heavily on runtime reflection.
// Ideal use cases:
// - Serverless functions (AWS Lambda, Azure Functions)
// - High-throughput microservices (fast cold start)
// - CLI tools shipped as single-file executables
// - IoT / embedded scenarios
// Poor fit:
// - Apps using extensive reflection (e.g., dynamic proxies)
// - Apps loading plugins at runtime
// - Apps depending on libraries that don't support trimming
// Key benefits:
// - Sub-10ms startup time (vs 200-500ms for JIT)
// - Lower memory at startup (no JIT overhead)
// - Smaller attack surface (no JIT engine)