Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET ahead-of-time: PublishReadyToRun vs PublishAot vs RunAOTCompilation

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?

like image 978
Rahul Avatar asked Dec 05 '25 13:12

Rahul


1 Answers

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.

like image 121
Andrew Arnott Avatar answered Dec 07 '25 03:12

Andrew Arnott



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!