![]() |
|
Blazor WebAssembly 3.2.0 Preview 1 release now available - Printable Version +- Sick Gaming (https://sickgaming.net) +-- Forum: Programming (https://sickgaming.net/forum-76.html) +--- Forum: C#, Visual Basic & .NET (https://sickgaming.net/forum-79.html) +--- Thread: Blazor WebAssembly 3.2.0 Preview 1 release now available (/thread-93425.html) |
Blazor WebAssembly 3.2.0 Preview 1 release now available - xSicKxBot - 01-31-2020 Blazor WebAssembly 3.2.0 Preview 1 release now available Daniel January 28th, 2020 Today we released a new preview update for Blazor WebAssembly with a bunch of great new features and improvements. Here’s what’s new in this release:
Get started To get started with Blazor WebAssembly 3.2.0 Preview 1 install the .NET Core 3.1 SDK and then run the following command: Code: dotnet new -i Microsoft.AspNetCore.Blazor.Templates::3.2.0-preview1.20073.1That’s it! You can find additional docs and samples on https://blazor.net. Upgrade an existing project To upgrade an existing Blazor WebAssembly app from 3.1.0 Preview 4 to 3.2.0 Preview 1:
Version updated to 3.2 In this release we updated the versions of the Blazor WebAssembly packages to 3.2 to distinguish them from the recent .NET Core 3.1 Long Term Support (LTS) release. There is no corresponding .NET Core 3.2 release – the new 3.2 version applies only to Blazor WebAssembly. Blazor WebAssembly is currently based on .NET Core 3.1, but it doesn’t inherit the .NET Core 3.1 LTS status. Instead, the initial release of Blazor WebAssembly scheduled for May of this year will be a Current release, which “are supported for three months after a subsequent Current or LTS release” as described in the .NET Core support policy. The next planned release for Blazor WebAssembly after the 3.2 release in May will be with .NET 5. This means that once .NET 5 ships you’ll need to update your Blazor WebAssembly apps to .NET 5 to stay in support. Simplified startup We’ve simplified the startup and hosting APIs for Blazor WebAssembly in this release. Originally the startup and hosting APIs for Blazor WebAssembly were designed to mirror the patterns used by ASP.NET Core, but not all of the concepts were relevant. The updated APIs also enable some new scenarios. Here’s what the new startup code in Program.cs looks like: Code: public class Program
{ public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add<App>("app"); await builder.Build().RunAsync(); }
}Blazor WebAssembly apps now support async Code: MainTo a create a default host builder, call Code: WebAssemblyHostBuilder.CreateDefault()Code: StartupThe following example adds a Code: WeatherServiceCode: public class Program
{ public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.Services.AddSingleton<WeatherService>(); builder.RootComponents.Add<App>("app"); await builder.Build().RunAsync(); }
}Once the host is built, you can access services from the root DI scope before any components have been rendered. This can be useful if you need to run some initialization logic before anything is rendered: Code: public class Program
{ public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.Services.AddSingleton<WeatherService>(); builder.RootComponents.Add<App>("app"); var host = builder.Build(); var weatherService = host.Services.GetRequiredService<WeatherService>(); await weatherService.InitializeWeatherAsync(); await host.RunAsync(); }
}The host also now provides a central configuration instance for the app. The configuration isn’t populated with any data by default, but you can populate it as required in your app. Code: public class Program
{ public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.Services.AddSingleton<WeatherService>(); builder.RootComponents.Add<App>("app"); var host = builder.Build(); var weatherService = host.Services.GetRequiredService<WeatherService>(); await weatherService.InitializeWeatherAsync(host.Configuration["WeatherServiceUrl"]); await host.RunAsync(); }
}Blazor WebAssembly apps run the .NET IL linker on every build to trim unused code from the app. In previous releases only the core framework libraries were trimmed. Starting with this release the Blazor framework assemblies are trimmed as well resulting in a modest size reduction of about 100 KB transferred. As before, if you ever need to turn off linking, add the Code: <BlazorLinkOnBuild>false</BlazorLinkOnBuild>Support for the .NET SignalR client You can now use SignalR from your Blazor WebAssembly apps using the .NET SignalR client. To give SignalR a try from your Blazor WebAssembly app:
Known issues Below is the list of known issues with this release that will get addressed in a future update.
Feedback We hope you enjoy the new features in this preview release of Blazor WebAssembly! Please let us know what you think by filing issues on GitHub. Thanks for trying out Blazor! Daniel Roth Principal Program Manager, ASP.NET Follow Daniel https://devblogs.microsoft.com/aspnet/author/danroth27/feed/ |