[Blazor] Enable Blazor apps running inside of ASP.NET Core to be Native AoT compiled
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
There are several issues around this topic, and none are very explicit.
This issue will track the work we need to do to make this happen.
AoT has become an important tech across the industry, with emphasis on cloud scenarios, performance and "leanness". As such, it's interesting for Blazor Applications (a subset at least) to be able to be compiled ahead of time.
AoT opens the door to new scenarios, such as:
- Running on devices with heavy constraints (e.g. IoT)
- Running on devices with constrained sandboxes (e.g. iOS). While .NET runs in these devices today, Native AOT is a guarantee that we can run anywhere.
- Providing Web Based UIs for CLI tools (e.g. dotnet tools).
It also enhances Blazor's ability to run on existing scenarios:
* Serverless (e.g. Azure Functions)
* Containers (e.g. Kubernetes)
In general, AoT brings in the following benefits:
* Reduced app size
* This is important for cloud scenarios where its desirable to achieve higher container density.
* Faster startup:
* This impacts cold starts of the application, which is important in serverless contexts.
* Scale out of rolling updates in Cloud scenarios.
* Reduced memory demand:
* AoT apps generally run with less memory compared to JIT apps, since there are many runtime components that are not needed.
* Increased performance:
* Many of the constraints imposed by AoT are addressed via optimizations that can be applied at compile time, which in many cases
leads to better performance.
* Enhanced security:
* AoT apps are less susceptible to runtime attacks, since the code is already compiled and there is no JITing happening at runtime.
* When running in container scenarios, you can "chisel" the container to only have the minimum code needed for the app to run, reducing the surface attack area.
## Goals/Scope of the work
* Investigate and list all the blockers that prevent the app from being AoT.
* Understand the available solutions for each problem (source generation, etc.)
* Identify the fixes that we think are valuable for other reasons (perf, better trimming, etc.)
* Prioritize the set of changes we want to tackle in .NET 9.0 to drive towards this scenario (low hanging fruit, performance, trimming)
## Reasoning
We only get the benefits of AoT if we remove all the blockers, so we want to reduce the cost as much as possible by making changes that provide immediate value for other reasons (perf, trimming, etc).
Contributor guide
Assessment
This issue has not been assessed yet.