Dogodek
Power BI DataViz Svetovno prvenstvo
14. feb., 16h - 31. mar., 16h
S 4 možnosti za vstop, bi lahko zmagal konferenčni paket in da bi bilo v ŽIVO Grand Finale v Las Vegasu
Več informacijTa brskalnik ni več podprt.
Izvedite nadgradnjo na Microsoft Edge, če želite izkoristiti vse prednosti najnovejših funkcij, varnostnih posodobitev in tehnične podpore.
gRPC supports .NET native ahead-of-time (AOT) in .NET 8. Native AOT enables publishing gRPC client and server apps as small, fast native executables.
Opozorilo
In .NET 8, not all ASP.NET Core features are compatible with Native AOT. For more information, see ASP.NET Core and Native AOT compatibility.
AOT compilation happens when the app is published. Native AOT is enabled with the PublishAot
option.
Add <PublishAot>true</PublishAot>
to the gRPC client or server app's project file. This will enable Native AOT compilation during publish and enable dynamic code usage analysis during build and editing.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<PublishAot>true</PublishAot>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Grpc.AspNetCore" Version="2.51.0" />
<PackageReference Include="Google.Protobuf" Version="3.22.0" />
</ItemGroup>
</Project>
Native AOT can also be enabled by specifying the -aot
option with the ASP.NET Core gRPC template:
dotnet new grpc -aot
Publish the app for a specific runtime identifier (RID) using dotnet publish -r <RID>
.
The app is available in the publish directory and contains all the code needed to run in it.
Native AOT analysis includes all of the app's code and the libraries the app depends on. Review Native AOT warnings and take corrective steps. It's a good idea to test publishing apps frequently to discover issues early in the development lifecycle.
A Native AOT executable contains just the code from external dependencies required to support the app. Unused code is automatically trimmed away.
The publish size of an ASP.NET Core gRPC service can be optimized by creating the host builder with WebApplication.CreateSlimBuilder()
. This builder provides a minimal list of features required to run an ASP.NET Core app.
var builder = WebApplication.CreateSlimBuilder(args);
builder.Services.AddGrpc();
var app = builder.Build();
app.MapGrpcService<GreeterService>();
app.Run();
Apps published with Native AOT have:
For more information and examples of the benefits that Native AOT provides, see Benefits of using Native AOT with ASP.NET Core.
Povratne informacije o izdelku ASP.NET Core
ASP.NET Core je odprtokodni projekt. Izberite povezavo za pošiljanje povratnih informacij:
Dogodek
Power BI DataViz Svetovno prvenstvo
14. feb., 16h - 31. mar., 16h
S 4 možnosti za vstop, bi lahko zmagal konferenčni paket in da bi bilo v ŽIVO Grand Finale v Las Vegasu
Več informacijUsposabljanje
Vodeno učenje
Create cloud-native apps and services with .NET and ASP.NET Core - Training
Create independently deployable, highly scalable, and resilient apps and services using the free and open-source .NET platform. With .NET you can use popular microservice technology like Docker, Kubernetes, Dapr, Azure Container Registry, and more for .NET and ASP.NET Core applications and services.
Dokumentacija
gRPC services with ASP.NET Core
Learn the basic concepts when writing gRPC services with ASP.NET Core.
Migrate gRPC from C-core to gRPC for .NET
Learn how to move an existing C-core based gRPC app to run on top of gRPC for .NET.
Create gRPC services and methods
Learn how to create gRPC services and methods.