Unable to use Hot Reload while debugging Blazor WASM (Aspnet hosted)

Viewed 1267

If I create a new Blazor WASM app, out of the box I can use Hot Reload by running dotnet watch run in a terminal window. This will launch a browser window, and any changes I make will update in the browser automatically.

However, if I start my app in Visual Studio with the debugger attached (F5), I don't get any hot reload functionality. When I make a change, Visual Studio shows a message in the bottom left that says Code Changes were applied successfully, but the browser does not refresh. If I refresh the browser manually, I still do not see my changes.

I have "Hot Reload on Save" checked. Pressing the new Hot Reload button doesn't seem to do anything.

The browser refresh script is injected into my html. <script src="/_framework/aspnetcore-browser-refresh.js"></script>

I am using Visual Studio 2022 Version 17.0.0 Preview 7.0, and dotnet 6 RC 2 (6.0.0-rc.2.21480.10).

Is it not possible to use Hot Reload while debugging a Blazor WASM app, or am I missing something?

2 Answers

Update

This bug has been fixed as of version 17.1 of Visual Studio 2022.


Posterity

This feature is currently unsupported when using the debugger in WebAssembly apps. According to Microsoft:

*In Visual Studio 2022 GA release Hot Reload support for Blazor WebAssembly when using the Visual Studio debugger isn’t enabled yet. You can still get Hot Reload If you start your app through Visual Studio without the debugger, and we are working to resolve this in the next Visual Studio update.

According to Microsoft, this will be fixed in the 17.1 release of VS 2022.

The fix will be included in the 17.1 release.

The latest preview version of Visual Studio 2022 (17.1.0 Preview 2 released Jan 5, 2022) contains the fix for this. I tested this personally and verified it's working. Note that you will still need to wait for 17.1 if you don't want to use the preview channel.

Now fixed, just update Visual Studio 2022 to the latest version (v17.1)!

When Microsoft first launched VS 2022 they clarified that Hot Reload was not fully supported for WASM and that they would hopefully be supporting it in a future patch of VS 2022.

https://devblogs.microsoft.com/dotnet/update-on-net-hot-reload-progress-and-visual-studio-2022-highlights/

Blazor Wasm being the one exception that only works today when launching your app without the debugger, but we will fix this in a future update as previously mentioned.

They have included the fix for this in VS 2022 version 17.1 which was officially released on February 15, 2022.

I updated and can confirm that hot reload while debugging is working for me!

Related