aspnetcore: Hot Reload unavailable

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I am using the latest VS2022 17.6.0 Preview 4.0

The preview version created the BlazorServer project, and all hot reloads were invalidated without any prompt. I am unable to determine the reason

dotnet watch ⌚ File changed: C:\Users\wf-so\Downloads\HotReloadIssue45519Demo-main\HotReloadIssue45519Demo-main\TradeCars\Client\Pages\Index.razor.
dotnet watch ⌚ No hot reload changes to apply.
dotnet watch 🔥 Hot reload capabilities: Baseline AddMethodToExistingType AddStaticFieldToExistingType NewTypeDefinition ChangeCustomAttributes.
dotnet watch ⌚ File changed: C:\Users\wf-so\Downloads\HotReloadIssue45519Demo-main\HotReloadIssue45519Demo-main\TradeCars\Client\Pages\Index.razor.
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2 POST https://localhost:5008/_framework/blazor-hotreload application/json 2835
dotnet watch ⌚ Received 0 from browser in [Count: 1, MessageType: Binary, EndOfMessage: True].
dotnet watch ⌚ Received failed apply from delta applier.
  ❔ Do you want to restart your app - Yes (y) / No (n) / Always (a) / Never (v)?

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

dotnet-sdk-7.0.203

Anything else?

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 15 (10 by maintainers)

Most upvoted comments

This is a direct successor to #45519, which was closed with “Likely fixed by https://github.com/dotnet/sdk/pull/31015.”, but it was not fixed. I wish someone would have tested it with the provided example before deeming it “likely fixed”. The test is very easy.

Here’s the minimal example, the same one that was provided in #45519, now upgraded to use SDK 7.0.302

szalapski/HotReloadIssue45519Demo

Clone this and run

dotnet watch --verbose --project ./TradeCars/Server

The site should start up. You’ll see Hot reload capabilities: . which portends the failure. Edit anything in Index.razor to watch hot reload fail.

Please get Hot Reload to work reliably and consistently with Blazor WebAssembly (and Blazor Server, likely the same problem), especially with changes to .razor files. This feature seems so buggy when it should “just work”. It seems to work much better with non-Blazor server-side changes, e.g. to a Web API, but that’s not where much productivity benefit would result.

When using dotnet watch on my Server project, with verbose logging , I get watch : Hot reload capabilities: . (not even Baseline) and, on a change, No hot reload changes to apply. (when there are). This is with .NET 7.0.5 and SDK 7.0.302 on a solution that was created with .NET 6 and recently upgraded to 7.

Starting...
dotnet watch 🔥 Hot reload capabilities: .
dotnet watch ⌚ File changed: .\MySoln\Client\Shared\MainLayout.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.
dotnet watch 🔥 Hot reload change handled in 4092.6926ms.

When running from VS (with or without debugging), I get similar output: image, or sometimes instead “Your debugged process might be corrupted and restarting it is recommended nearly always.”

See also:

Seems like there are a lot of others struggling too but not commenting in GitHub issues, e.g.

Expected Behavior

  • dotnet watch hot reload should just work. I don’t want to see “No hot reload changes to apply.”
  • If it isn’t working and thus I get “watch : Hot reload capabilities: .”, I’d like to see output that tells me why in the verbose output (indeed, perhaps even in warnings).

Thanks @tmat. I got rid of the notion of “Developer” in my demo app, instead using “Development”, and I modified Program.cs accordingly, and I still see no change. I still get dotnet watch ⌚ No hot reload changes to apply. Would you be willing to pull the latest and run the demo app (see README.md) and see if you can get HotReload to work?

https://github.com/szalapski/HotReloadIssue45519Demo

@szalapski Not currently, but fixing that: https://github.com/dotnet/aspnetcore/pull/48953

Meanwhile you may consider changing developer -> development and development -> deployed, or something like that.