Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable Blazor hot reload

Having watched Dan Roth's Blazor demo (15 Jan 2020), code changes to a razor file were refreshed to the browser without the stop|build|run cycle. On my VS2019 (latest) I don't get that hot reload. This is a new Blazor SS project from the standard template. Is there a property required to be set to enable it?

I tried dotnet run watch but no difference

like image 296
Craig Avatar asked Nov 06 '22 10:11

Craig


1 Answers

Edit: 12-04-2021

Initial .NET Hot Reload support Early support for .NET Hot Reload is now available for ASP.NET Core & Blazor projects using dotnet watch. .NET Hot Reload applies code changes to your running app without restarting it and without losing app state.

To try out hot reload with an existing ASP.NET Core project based on .NET 6, add the "hotReloadProfile": "aspnetcore" property to your launch profile in launchSettings.json. For Blazor WebAssembly projects, use the "blazorwasm" hot reload profile.

Run the project using dotnet watch. The output should indicate that hot reload is enabled:

watch : Hot reload enabled. For a list of supported edits, see https://aka.ms/dotnet/hot-reload. Press "Ctrl + R" to restart. If at any point you want to force the app to rebuild and restart, you can do so by entering Ctrl+R at the console.

You can now start making edits to your code. As you save code changes, applicable changes are automatically hot reloaded into the running app almost instantaneously. Any app state in the running app is preserved.

OLD ANSWER

This will come in .NET 6 hopefully. But at the time of writing this is still not working yet:

enter image description here

like image 137
Flores Avatar answered Dec 01 '22 18:12

Flores