03-06-2019, 09:48 PM
Blazor 0.8.0 experimental release now available
Blazor 0.8.0 is now available! This release updates Blazor to use Razor Components in .NET Core 3.0 and adds some critical bug fixes.
Get Blazor 0.8.0
To get started with Blazor 0.8.0 install the following:
You can find getting started instructions, docs, and tutorials for Blazor at https://blazor.net.
Upgrade to Blazor 0.8.0
To upgrade your existing Blazor apps to Blazor 0.8.0 first make sure you’ve installed the prerequisites listed above.
To upgrade a standalone Blazor 0.7.0 project to 0.8.0:
To upgrade an ASP.NET Core hosted Blazor app to 0.8.0:
To upgrade a Blazor class library to 0.8.0:
Server-side Blazor is now ASP.NET Core Razor Components in .NET Core 3.0
As was recently announced, server-side Blazor is now shipping as ASP.NET Core Razor Components in .NET Core 3.0. We’ve integrated the Blazor component model into ASP.NET Core 3.0 and renamed it to Razor Components. Blazor 0.8.0 is now built on Razor Components and enables you to host Razor Components in the browser on WebAssembly.
Upgrade a server-side Blazor project to ASP.NET Core Razor Components in .NET Core 3.0
If you’ve been working with server-side Blazor, we recommend upgrading to use ASP.NET Core Razor Components in .NET Core 3.0.
To upgrade a server-side Blazor app to ASP.NET Core Razor Components:
Switching between ASP.NET Core Razor Components and client-side Blazor
Sometimes it’s convenient to be able to switch between running your Razor Components on the server (ASP.NET Core Razor Components) and on the client (Blazor). For example, you might run on the server during development so that you can easily debug, but then publish your app to run on the client.
To update an ASP.NET Core hosted Blazor app so that it can be run as an ASP.NET Core Razor Components app:
Previously to get tooling support for Blazor projects you needed to install the Blazor extension for Visual Studio. Starting with Visual Studio 2019 Preview 2, tooling support for Razor Components (and hence Blazor apps) is already included without having to install anything else. The Blazor extension is now only needed to install the Blazor project templates in Visual Studio.
Runtime improvements
Blazor 0.8.0 includes some .NET runtime improvements like improved runtime performance on Chrome and an improved IL linker. In our performance benchmarks, Blazor 0.8.0 performance on Chrome is now about 25% faster. You can now also reference existing libraries like Json.NET from a Blazor app without any additional linker configuration:
Known issues
There are a couple of known issues with this release that you may run into:
These issues will be addressed in a future Blazor update.
Future updates
This release of Blazor was primarily focused on first integrating Razor Components into ASP.NET Core 3.0 and then rebuilding Blazor on top of that. Going forward, we plan to ship Blazor updates with each .NET Core 3.0 update.
Blazor, and support for running Razor Components on WebAssembly in the browser, won’t ship with .NET Core 3.0, but we continue to work towards shipping Blazor some later date.
Give feedback
We hope you enjoy this latest preview release of Blazor. As with previous releases, your feedback is important to us. If you run into issues or have questions while trying out Blazor, file issues on GitHub. You can also chat with us and the Blazor community on Gitter if you get stuck or to share how Blazor is working for you. After you’ve tried out Blazor for a while please let us know what you think by taking our in-product survey. Click the survey link shown on the app home page when running one of the Blazor project templates:
Thanks for trying out Blazor!
Blazor 0.8.0 is now available! This release updates Blazor to use Razor Components in .NET Core 3.0 and adds some critical bug fixes.
Get Blazor 0.8.0
To get started with Blazor 0.8.0 install the following:
- .NET Core 3.0 Preview 2 SDK (3.0.100-preview-010184)
- Visual Studio 2019 (Preview 2 or later) with the ASP.NET and web development workload selected.
- The latest Blazor extension from the Visual Studio Marketplace.
- The Blazor templates on the command-line:
Code:dotnet new -i Microsoft.AspNetCore.Blazor.Templates::0.8.0-preview-19104-04
You can find getting started instructions, docs, and tutorials for Blazor at https://blazor.net.
Upgrade to Blazor 0.8.0
To upgrade your existing Blazor apps to Blazor 0.8.0 first make sure you’ve installed the prerequisites listed above.
To upgrade a standalone Blazor 0.7.0 project to 0.8.0:
- Update the Blazor packages and .NET CLI tool references to 0.8.0-preview-19104-04.
- Replace any package reference to Microsoft.AspNetCore.Blazor.Browser with a reference to Microsoft.AspNetCore.Blazor.
- Replace withCode:
BlazorComponent.Code:ComponentBase
- Update overrides of on components to overrideCode:
SetParametersinstead.Code:SetParametersAsync
- Replace withCode:
BlazorLayoutComponentCode:LayoutComponentBase
- Replace withCode:
IBlazorApplicationBuilder.Code:IComponentsApplicationBuilder
- Replace any using statements for withCode:
Microsoft.AspNetCore.Blazor.*, except leaveCode:Microsoft.AspNetCore.Components.*in Program.csCode:Microsoft.AspNetCore.Blazor.Hosting
- In index.html update the script reference to reference components.webassembly.js instead of blazor.webassembly.js
To upgrade an ASP.NET Core hosted Blazor app to 0.8.0:
- Update the client-side Blazor project as described previously.
- Update the ASP.NET Core app hosting the Blazor app to .NET Core 3.0 by following the migrations steps in the ASP.NET Core docs.
- Update the target framework to be Code:
netcoreapp3.0
- Remove any package reference to Microsoft.AspNetCore.App or Microsoft.AspNetCore.All
- Upgrade any non-Blazor Microsoft.AspNetCore.* package references to version 3.0.0-preview-19075-0444
- Remove any package reference to Microsoft.AspNetCore.Razor.Design
- To enable JSON support, add a package reference to Microsoft.AspNetCore.Mvc.NewtonsoftJson and updateto callCode:
Startup.ConfigureServicesCode:services.AddMvc().AddNewtonsoftJson()
- Update the target framework to be
- Upgrade the Microsoft.AspNetCore.Blazor.Server package reference to 0.8.0-preview-19104-04
- Add a package reference to Microsoft.AspNetCore.Components.Server
- In simplify any call toCode:
Startup.ConfigureServicesto call the default overload without specifying WebAssembly or binary data as additional MIME types to compress.Code:app.AddResponseCompression
- In add a call toCode:
Startup.Configureafter the existing call toCode:app.UseBlazorDebugging()Code:app.UseBlazor<App.Startup>()
- Remove any unnecessary use of the namespace.Code:
Microsoft.AspNetCore.Blazor.Server
To upgrade a Blazor class library to 0.8.0:
- Replace the package references to Microsoft.AspNetCore.Blazor.Browser and Microsoft.AspNetCore.Blazor.Build with references to Microsoft.AspNetCore.Components.Browser and Microsoft.AspNetCore.Components.Build and update the versions to 3.0.0-preview-19075-0444.
- In the project file for the library change the project SDK from “Microsoft.NET.Sdk.Web” to “Microsoft.NET.Sdk.Razor”.
Server-side Blazor is now ASP.NET Core Razor Components in .NET Core 3.0
As was recently announced, server-side Blazor is now shipping as ASP.NET Core Razor Components in .NET Core 3.0. We’ve integrated the Blazor component model into ASP.NET Core 3.0 and renamed it to Razor Components. Blazor 0.8.0 is now built on Razor Components and enables you to host Razor Components in the browser on WebAssembly.
Upgrade a server-side Blazor project to ASP.NET Core Razor Components in .NET Core 3.0
If you’ve been working with server-side Blazor, we recommend upgrading to use ASP.NET Core Razor Components in .NET Core 3.0.
To upgrade a server-side Blazor app to ASP.NET Core Razor Components:
- Update the client-side Blazor project as described previously, except replace the script reference to blazor.server.js with components.server.js
- Update the ASP.NET Core app hosting the Razor Components to .NET Core 3.0 as described previously.
- In the server project:
- Upgrade the Microsoft.AspNetCore.Blazor.Server package reference to 0.8.0-preview-19104-04
- Add a package reference to Microsoft.AspNetCore.Components.Server version 3.0.0-preview-19075-0444
- Replace the using statement for withCode:
Microsoft.AspNetCore.Blazor.ServerCode:Microsoft.AspNetCore.Components.Server
- Replace withCode:
services.AddServerSideBlazorandCode:services.AddRazorComponentswithCode:app.UseServerSideBlazor.Code:app.UseRazorComponents
- In the method addCode:
Startup.Configurejust prior to callingCode:app.UseStaticFiles().Code:app.UseRazorComponents
- Move the wwwroot folder from the Blazor app project to the ASP.NET Core server project
- Upgrade the Microsoft.AspNetCore.Blazor.Server package reference to 0.8.0-preview-19104-04
Switching between ASP.NET Core Razor Components and client-side Blazor
Sometimes it’s convenient to be able to switch between running your Razor Components on the server (ASP.NET Core Razor Components) and on the client (Blazor). For example, you might run on the server during development so that you can easily debug, but then publish your app to run on the client.
To update an ASP.NET Core hosted Blazor app so that it can be run as an ASP.NET Core Razor Components app:
- Move the wwwroot folder from the client-side Blazor project to the ASP.NET Core server project.
- In the server project:
- Update the script tag in index.html to point to components.server.js instead of components.webassembly.js.
- Add a call to in theCode:
services.AddRazorComponents<Client.Startup>()method.Code:Startup.ConfigureServices
- Add a call to in theCode:
app.UseStaticFiles()method prior to the call toCode:Startup.Configure.Code:UseMvc
- Replace the call to withCode:
UseBlazorCode:app.UseRazorComponents<Client.Startup>()
- Update the script tag in index.html to point to components.server.js instead of components.webassembly.js.
- If you’re using dependency injection to inject an into your components, then you’ll need to add anCode:
HttpClientas a service in your server’sCode:HttpClientmethod.Code:Startup.ConfigureServices
Previously to get tooling support for Blazor projects you needed to install the Blazor extension for Visual Studio. Starting with Visual Studio 2019 Preview 2, tooling support for Razor Components (and hence Blazor apps) is already included without having to install anything else. The Blazor extension is now only needed to install the Blazor project templates in Visual Studio.
Runtime improvements
Blazor 0.8.0 includes some .NET runtime improvements like improved runtime performance on Chrome and an improved IL linker. In our performance benchmarks, Blazor 0.8.0 performance on Chrome is now about 25% faster. You can now also reference existing libraries like Json.NET from a Blazor app without any additional linker configuration:
Code:
@functions { WeatherForecast[] forecasts;
protected override async Task OnInitAsync() { var json = await Http.GetStringAsync("api/SampleData/WeatherForecasts"); forecasts = Newtonsoft.Json.JsonConvert.DeserializeObject<WeatherForecast[]>(json); }
}There are a couple of known issues with this release that you may run into:
- “It was not possible to find any compatible framework version. The specified framework ‘Microsoft.NETCore.App’, version ‘2.0.0’ was not found.”: You may see this error when building a Blazor app because the IL linker currently requires .NET Core 2.x to run. To work around this issue, either install .NET Core 2.2 or disable IL linking by setting the property in your project file.Code:
<BlazorLinkOnBuild>false</BlazorLinkOnBuild>
- “Unable to generate deps.json, it may have been already generated.”: You may see this error when running a standalone Blazor app and you haven’t yet restored packages for any .NET Core apps. To workaround this issue create any .NET Core app (ex ) and then rerun the Blazor app.Code:
dotnet new console
These issues will be addressed in a future Blazor update.
Future updates
This release of Blazor was primarily focused on first integrating Razor Components into ASP.NET Core 3.0 and then rebuilding Blazor on top of that. Going forward, we plan to ship Blazor updates with each .NET Core 3.0 update.
Blazor, and support for running Razor Components on WebAssembly in the browser, won’t ship with .NET Core 3.0, but we continue to work towards shipping Blazor some later date.
Give feedback
We hope you enjoy this latest preview release of Blazor. As with previous releases, your feedback is important to us. If you run into issues or have questions while trying out Blazor, file issues on GitHub. You can also chat with us and the Blazor community on Gitter if you get stuck or to share how Blazor is working for you. After you’ve tried out Blazor for a while please let us know what you think by taking our in-product survey. Click the survey link shown on the app home page when running one of the Blazor project templates:
Thanks for trying out Blazor!

