DEV Community

David Guida
David Guida

Posted on • Updated on

How to migrate Blazor Webassembly to .NET 5

.NET 5 is out today! It's a big milestone and comes with a huge list of improvements. I've been working a bit with Blazor lately, trying to brush up my gamedev skills again. So I took the chance and decided to upgrade my little pet project to the latest version :)

The first thing to do is to install or update Visual Studio 2019 to version 16.8.0. For those interested, the release notes are available here. In case you're using a different IDE (or you're on Linux/Mac), you can directly download the .NET 5 SDK instead.

Once you've done installing, fire up your Blazor project and open the .csproj file. We're going to change few little things:

  1. At the very top, update the SDK from Microsoft.NET.Sdk.Web to Microsoft.NET.Sdk.BlazorWebAssembly
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
Enter fullscreen mode Exit fullscreen mode

2. Set the TargetFramework to net5.0

3. In case you have it, remove the package reference to Microsoft.AspNetCore.Components.WebAssembly.Build

4. Update your Nuget dependencies

Now make sure you Clean your entire solution, otherwise, the build engine won't be able to re-generate all the required files with the updated framework.

Enjoy!

Top comments (0)