The recent .NET version (.NET 6 & 7) has an ahead-of-time (AOT) compilation feature. According to the official documentation, there are different approaches to achieving this.
Native AOT Deployment
<PropertyGroup>
<PublishAot>true</PublishAot>
</PropertyGroup>
ReadyToRun Compilation
<PropertyGroup>
<PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>
AOT Blazor WebAssembly
<PropertyGroup>
<RunAOTCompilation>true</RunAOTCompilation>
</PropertyGroup
It's quite hard to understand the concept by just reading the documentation. What is the difference between the PublishReadyToRun vs PublishAot? When should I use one over the other? And how can I enable AoT compilation for class libraries, Blazor WebAssembly, and ASP.NET Core projects?
PublishAOT will not ship a JIT with your application. Many reflection APIs will fail at runtime. You will be unable to load .NET assemblies into your application at runtime, so your app won't be extensible in the traditional .NET ways.
PublishReadyToRun gives you some or most of the perf benefit of AOT without the added restrictions that PublishAOT brings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With