Skip to content

Native AOT

Native AOT compiles .NET apps to native code for lower memory and fast startup.

Notes

  • Not all libraries are compatible; avoid dynamic code generation and reflection-heavy patterns.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<PublishAot>true</PublishAot>
<InvariantGlobalization>true</InvariantGlobalization>
<TrimMode>full</TrimMode>
</PropertyGroup>
</Project>

Publish:

Terminal window
dotnet publish -c Release -r win-x64 --self-contained true
using System;
Console.WriteLine("Hello AOT!");