Using native AOT with ASP.NET Core
Comparing Docker images with VM images, Docker images are a lot smaller as they don’t need to contain the operating system. With ASP.NET Core applications, the Docker image contains the application – and the .NET runtime. Over the last years, images have become smaller because more and more optimization has been done. Having smaller images means faster startup of the application.
Since .NET 7, it’s possible to create native applications with C# using native AOT. With this, many changes are required with .NET. With .NET 7, the native AOT functionality was very limited. With .NET 8, we can already create ASP.NET Core services, which results in faster startup and less memory footprint.
Using native AOT, an AOT compiler is used to compile Intermediate Language (IL) code to native code. At build time, we still use the normal build process and the .NET runtime because native compilation takes some time. The native AOT compilation...