.NET › .NET CLI, SDK & Project Structure (csproj)
What is Native AOT (Ahead-of-Time) compilation, and what are its benefits and constraints?
AdvancedAnswer
Native AOT compiles a .NET application directly to native machine code at publish time, producing a fully self-contained native executable with no JIT compilation or full .NET runtime required at startup -- resulting in dramatically faster startup time and lower memory footprint, ideal for CLI tools, containers, and serverless functions. Constraints include no runtime reflection-based dynamic code generation, limited support for some libraries, and platform-specific builds required per target.
dotnet publish -c Release -r linux-x64 -p:PublishAot=true
# Produces a native executable with no separate .NET runtime dependency,
# starting in milliseconds instead of the usual JIT warm-up timeReal-world example A serverless function deployed to AWS Lambda uses Native AOT to cut cold-start latency from several hundred milliseconds down to under 50ms, directly improving cost and user-perceived performance.