Closed DamianEdwards closed 11 months ago
There is any native aot for blazor wasm?? Native aot for that can be very very hopeful and nice solution for performance issues like size and startup time
@sajjadarashhh Blazor WebAssembly runs on Mono which has its own native compilation toolchain, separate to native AOT for .NET.
As such, Blazor WebAssembly already supports AOT compilation: https://learn.microsoft.com/aspnet/core/blazor/host-and-deploy/webassembly#ahead-of-time-aot-compilation
@DamianEdwards but native aot is not equal to that when we have that dotnet.wasm must be smaller and quicker at startup
@sajjadarashhh at any rate, this issue is about enabling native AOT for ASP.NET Core apps targeting CoreCLR. Please log a separate issue regarding performance and size of Blazor WebAssembly AOT if you wish to discuss that.
The following feature areas are out of scope for native AOT support for now:
- MVC views and Razor Pages
- Blazor Server
That's very unfortunate. I have Blazor Hybrid (WebKitGTK on Linux) applications running on ARM64 that take much too long to start up. If I publish them with NativeAoT, they start up very quickly, but they don't render the UI or they segfault.
That's very unfortunate. I have Blazor Hybrid (WebKitGTK on Linux) applications running on ARM64 that take much too long to start up. If I publish them with NativeAoT, they start up very quickly, but they don't render the UI or they segfault.
Thanks for the feedback @JinShil - getting ASP.NET running on the native AOT deployment model is a process. As we achieve each milestone, we can re-evaluate features that are currently out of scope.
Would like to see NativeAOT support for razor component too.
The following feature areas are out of scope for native AOT support for now:
MVC views and Razor Pages Blazor Server
Is there any plan to support Blazor Server with NativeAOT ? maybe .net9 ?
Is there any plan to support Blazor Server with NativeAOT ? maybe .net9 ?
Not concrete yet, but it's certainly in the list of areas to consider.
@DamianEdwards - can this Epic be closed now that 8.0 has shipped?
Will AOT ASP.NET Core ever support Https.
Our company (as many financial sector companies have) is a policy that all data has to be encrypted both in flight and at rest. It would be a shame to miss out on all the AOT goodness simply because HTTPS is not supported.
Thanks Stephen
My understanding is that is supported in .NET 8: Reduced app size with configurable HTTPS support
@SquareHatLtd HTTPS is supported, but if using WebApplication.CreateSlimBuilder
you need to add HTTPS support for Kestrel back in as it's not included in the defaults, e.g.:
var builder = WebApplication.CreateSlimBuilder(args);
builder.WebHost.UseKestrelHttpsConfiguration();
The team has done some truly remarkable work on this feature, thank you! Just checking whether there is any update on plans for Stage 2.b, particularly w.r.t OpenAPI/Swagger. Thanks again!
@w-as - do you need your OpenAPI/Swagger endpoint in production? One approach we took in the TodosApi benchmark app was to make it a development-only time feature. See
@w-as - do you need your OpenAPI/Swagger endpoint in production? One approach we took in the TodosApi benchmark app was to make it a development-only time feature. See
Chiming in here. In some of our apps, we make it development-only as well. But we provide a lot of utility via our OpenAPI/Swagger endpoints and we actually have a customer that prefers we ship with Swagger in prod. There are absolutely alternatives to this, but it would be nice to see support at some point for OpenAPI in Native AOT (although it is not at all necessary, would be extra brownie points). The bigger blocker for us in moving some apps to Native AOT is lack of SignalR support. Hoping to see this roadmapped soon!
@w-as - do you need your OpenAPI/Swagger endpoint in production? One approach we took in the TodosApi benchmark app was to make it a development-only time feature. See
I'm sorry I missed your response back in November, thank you for the suggestion of dev-time only. We do currently publish the OpenAPI/Swagger endpoints in production yes, however it may be possible to create clients based on dev-time specs so will investigate that, thank you.
Great job there! Is Stage 2.b targeted for .NET 9? SignalR at least?
Is Stage 2.b targeted for .NET 9? SignalR at least?
Check out the update to this issue: https://github.com/dotnet/aspnetcore/issues/41704#issuecomment-2190200815. My plan is to get SignalR support with the JSON protocol in for .NET 9 preview 7.
Overview
.NET 7 introduced support for publishing .NET console projects as native AOT, producing a self-contained, platform-specific executable without any runtime JIT. Native AOT apps start up very quickly and use less memory. The application can be deployed to a machine or container that doesn't have any .NET runtime installed. In .NET 8 we will extend support for native AOT to ASP.NET Core, starting with cloud-focused, API applications built with Minimal APIs that meet expectations regarding published file size, startup time, working set, and throughput performance.
Scope
As stated, the primary focus for .NET 8 will be on enabling native AOT publish of ASP.NET Core API applications using Minimal APIs. "Support native AOT" in this context means ensuring that projects can enable native AOT publish via the
<PublishAOT>
project property and the resulting development experience leads developers to producing native AOT published applications without build, publish, or runtime warnings and errors. This means that the majority of foundational feature areas of ASP.NET Core and .NET will need to be updated to support native AOT, including:WebApplication
, etc.Additionally, as a secondary goal, we will make progress towards enabling native AOT publish for the following feature areas:
The following feature areas are out of scope for native AOT support for now:
Development experience principles
Native AOT has limitations that mean certain APIs and code patterns in .NET are not supported when publishing native AOT. These include features that rely on runtime JIT, e.g. dynamic code generation and compilation, assembly loading, etc., as well as patterns that result in code being trimmed away by the native AOT compilation process that is needed to execute the application, resulting in runtime failures.
In adding support to ASP.NET Core for native AOT, we must ensure that the development experience is such that developers can reasonably determine how their app will run once published as native AOT. Where current APIs and features are designed in such a way that are incompatible with native AOT, we will utilize tools including source generators, analyzers, and code fixers, to allow existing APIs to work with native AOT or for developers to update their apps to work with native AOT in a reasonable fashion.
Stages
Stage 1
Stage 1 of this effort will be to enable creation of ASP.NET Core API projects using a new project template, enabled for native AOT, that can be built, published, and run without any warnings or errors, and that meets the defined metric targets for executable file size, startup time, working set, and throughput.
Metric Targets
These are primarily Linux-focused as that's the primary deployment target, but size on Windows on macOS will still be tracked and kept in line with these targets as it often contributes to perception during candidate platform investigations.
Stage 2
Stage 2 builds on stage 1 to enable more "real-world" ASP.NET Core API applications to be native AOT published. These applications will use more features typically associated with running API applications in cloud environments including AuthN/Z, data access, OpenTelemetry, etc. The TrimmedTodo API application will serve as the initial example of this kind of application.
Stage 2.a
Feature areas to be made compatible with native AOT in stage 2.a as part of .NET 8:
Metric Targets
These are primarily Linux-focused as that's the primary deployment target, but size on Windows on macOS will still be tracked and kept in line with these targets as it often contributes to perception during candidate platform investigations.
Stage 2.b
Feature areas to be made compatible with native AOT in stage 2.b, likely beyond .NET 8. Note that work towards native AOT compatibility for these areas will likely begin in .NET 8, but not be completed: