aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

Hotreload doesn't work on Blazor wasm (.NET6)

Open darius-khll opened this issue 2 years ago • 8 comments

Hotreload doesn't work on blazor wasm (.NET6 LTS)

I've created a brand new blazor wasm project using Visual Studio 2022 (Version 17.1.0 Preview 1.1) and couldn't get hotreload to work, HOWEVER it works perfectly fine on blazor server!

To Reproduce

Windows 11 Brand new .NET6 blazor wasm project and then run "dotnet watch" as soon as something is changed it's gonna end up with this particular message and should be restarted manually!

watch : File changed: C:\Users\alikh\source\repos\BlazorApp1\BlazorApp1\Pages\Index.razor.
watch : No hot reload changes to apply.

darius-khll avatar Nov 22 '21 20:11 darius-khll

@pranavkm Can you suggest any diagnostic steps here? There's not much information to indicate what might be wrong.

SteveSandersonMS avatar Nov 25 '21 15:11 SteveSandersonMS

@SteveSandersonMS Please provide what exactly I'm meant to do, let me know and I'll be doing that ASAP :) meanwhile I'll be looking for a way to find out potential logs and so on

darius-khll avatar Nov 25 '21 21:11 darius-khll

It's so bizarre actually, I just realized it works using this command "Dotnet watch --project ." is it something particularly different in that way? I couldn't find it in official documentation, I just bumped into that one in some forums..

darius-khll avatar Nov 25 '21 21:11 darius-khll

However it won't be working using that certain trick for blazorwasm hosted with asp.net core :(

darius-khll avatar Nov 25 '21 22:11 darius-khll

Thanks for contacting us.

We're moving this issue to the .NET 7 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

ghost avatar Nov 30 '21 17:11 ghost

Thanks for contacting us.

We're moving this issue to the .NET 7 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

Umm I'm going to raise a flag here because for me it extends to the hosting environment also (meaning no clients receive updates after changes are published) and I think it's related. Please see my comment on this same topic in another issue thread https://github.com/dotnet/aspnetcore/issues/38809#issuecomment-985967854

Aquaritek avatar Dec 04 '21 04:12 Aquaritek

This seems not to be fixed in SDK 6.0.200--when I do dotnet watch --project . from the Server directory, wait for it to spin up and load the page, then change the text on the page, I still get:

watch : File changed: C:\...\Client\...\MyComponent.razor.
watch : No hot reload changes to apply.

With --verbose, I get:

watch : File changed: C:\...\Client\...\MyComponent.razor.
watch : No deltas modified. Applying changes to clear diagnostics.
watch : Received 1 from browser in [Count: 1, MessageType: Binary, EndOfMessage: True].
watch : No hot reload changes to apply.
watch : Hot reload change handled in 5902.7638ms.

There are hot reload changes to apply. Come on, it is so close to working! Can anyone help?

szalapski avatar Feb 24 '22 19:02 szalapski

@tmat can you please look into this? This may already be fixed but wanted you to confirm.

mkArtakMSFT avatar Aug 10 '22 17:08 mkArtakMSFT

This is happening to me also. Creating a new ASP.NET Core Hosted Web Assembly app and running dotnet watch from the Server directory.

ChristopherHaws avatar Sep 07 '22 06:09 ChristopherHaws

After trying and re-trying this and reconsidering it each time, I found that when I first start dotnet watch it works for me for several iterations, rebuilding automatically and reloading my page, before eventually (5 or 20 minutes later) it stops working and I get the bogus "No hot reload changes to apply", when it won't rebuild even though it should.

What information more is needed to troubleshoot this, beyond --verbose?

EDIT: now it is failing much more often, perhaps right away or after just a minute or too. Still getting bogus "No hot reload changes to apply." messages in the verbose output.

szalapski avatar Sep 16 '22 03:09 szalapski

Did anyone find a solution? I moved to .NET 7 November release , it is still happening. dotnet watch or dotnet watch run they work well when first editing a file, after that:

dotnet watch ⌚ File changed: ./Pages/Index.razor.
dotnet watch ⌚ No hot reload changes to apply.

MarcoMedrano avatar Nov 26 '22 15:11 MarcoMedrano

See also https://github.com/dotnet/aspnetcore/issues/45519

szalapski avatar Feb 08 '23 22:02 szalapski

This worked for me (.net 6 and .net 7):

  • Install NuGet package: Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
  • Add line in Startup.cs: services.AddControllersWithViews().AddRazorRuntimeCompilation();
  • Or in Program.cs: builder.Services.AddControllersWithViews().AddRazorRuntimeCompilation();

pedrinCjm avatar Feb 21 '23 12:02 pedrinCjm

Tried that, @pedrinCjm, but it didn't help me. I still get:

Starting...
dotnet watch 🔥 Hot reload capabilities: .
dotnet watch ⌚ File changed: .\Client\Pages\Index.razor.
dotnet watch ⌚ No deltas modified. Applying changes to clear diagnostics.
dotnet watch ⌚ Received 1 from browser in [Count: 1, MessageType: Binary, EndOfMessage: True].
dotnet watch ⌚ No hot reload changes to apply.

szalapski avatar Feb 21 '23 16:02 szalapski

We have made multiple changes to address dotnet watch reliability. If the issue still reproduces with the latest .NET 8 SDK preview, please reopen the issue with --verbose output, the project it reproes with and what changes are made to the files.

tmat avatar Sep 25 '23 23:09 tmat