-
Notifications
You must be signed in to change notification settings - Fork 9.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hot Reload nearly always fails, with Blazor WebAssembly and "dotnet watch" #45519
Comments
Hot Reload is just terrible. I feel bad criticising any of this because in the end it's a 'free' framework that most of us haven't helped to develop, but... There is absolutely no point in allowing and/or promoting the existence of hot reload in its current state. It is rubbish, useless, pointless. Every little change (and sometimes no change at all) requires a rebuild. It isn't 'hot reload' AT ALL. |
I don't feel bad, but I hope my criticism is constructive and optimistic. I want to help, too, but no idea how I can, as there is no clue as to what is wrong when Hot Reload fails. For what it's worth, I wouldn't mind so much an automatic rebuild--my main concern in this issue is that I get |
Thanks for sharing this feedback. We are aware that there are a number of issues with hot reload we are trying to address. In order for us to address the issue you're facing, could you please provide a repro project hosted as a public GitHub repo that demonstrates the problem? |
Hi @szalapski. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
@szalapski Have you tried cleaning out the bin and obj folders and rebuilding? |
@danroth27 Yes, but I just tried it again to be sure. Deleted bin and obj in all three projects (Server, Client, Shared), and ran
@MackinnonBuck, I'll try to get a example project up ASAP. |
@MackinnonBuck , here's the minimal example as requested. https://github.com/szalapski/HotReloadIssue45519Demo Clone this and run
The site should start up. You'll see |
@tmat given the repro is provided, I'm assigning this to you to investigate. Thanks! |
Thanks for contacting us. We're moving this issue to the |
Thanks for investigating...I must say, I think this should be targeted for a more urgent fix release for .NET 7, as it was supposed to be working in .NET 6. |
We have been working with Blazor for three years now, but are seriously contemplating switching everything to React solely because of this issue. The development experience is beyond painful - it would be better to switch the feature off and set the expectation that you always have to recompile. It's the "waiting to see if it works, knowing it probably won't" that kills all motivation and enthusiasm. |
@tmat, I'm curious if you are able to reproduce with that repo. |
I 100% have this issue. It makes development very slow unfortunately =( |
I did a few quick tests with 7.0.101 and VS 17.4.3:
This is being investigated. |
For me is always No hot reload changes to apply |
I've managed to get hot reload working for .NET 6 and .NET 7 Blazor WebAssembly using I use VS Code DevContainers, and the following command works for me: Please note that I use the following base image: Targeting .NET 6, I hope this helps someone else struggling here. |
Honestly, doesn't help at all. It should just work. No need for hacky convoluted workarounds. |
@Andreas02-dev , thanks for the tip, though it didn't help for me either. I still get
@danroth27, thanks for doing that. Any learnings from the investigation yet? |
Yeah, it can be a bit spotty sometimes. From personal experience, re-running the command a few times usually does the trick. Sometimes, it'll 'apply' the changes (but it won't) so you'll need to run the command again. I'm afraid I don't currently know how to make it work in your case, but I do hope they will |
For me, hot reloading works for a very simple new Blazor Server project out of the box, but does not work on the much larger, more complex, real-world project that I worked on. I tried so many things to try to get hot reloading to work, and what finally allowed it to work was installing version 4.5.0 of the Microsoft.CodeAnalysis.Common Nuget package. Something my project had referenced was implicitly installing version 4.4.0 of this package, and I guess for some reason, that one doesn't work with hot reloading (?). I hope this helps someone else who might have the same problem. (I'm using .NET version 7.0.201 by the way) I almost forgot, this seems to be important too. My launchSettings.json looks like this: I found that I had to have
EDIT: So here I am 5 days later on 3/8/2023, and hot reloading no longer works for me, even with this "fix". At best it is inconsistent I guess. It is very frustrating not knowing what causes it not to work 😞 |
I am throwing my hat in the ring. This problem has been plaguing me for months. Blazor WASM .NET7 in VS 20222 Version 17.5.3. Often getting the "No hot reload changes to apply.". The problem happens both in |
|
If you add a new property it's gonna need to recompile. But there are still plenty of times when it wants to recompile even though it shouldn't. For example, changing a value assignment on something that is already compiled, i.e. 'Edit and Continue' which is pretty much the thing that is failing in such a case, and has failed in various ways for years already, even before Blazor came about. I really wish Microsoft would fix this, or at least explain why it's not possible to do so. |
Hmm ok. So under what scenarios should Hot Reload works on Razor Web Assembly? |
The one thing that should work every time is when you modify the mark-up of any component. There are probably some underlying complexities to that, but the way hot reload is advertised, I would expect any update to propagate into the UI without needing to stop debugging. There is also the aforementioned 'Edit and Continue' which has been a thing in .NET for a very long time. It's more temperamental nowadays. |
@dodyg @Stuart88 With Blazor WebAssembly the runtime is much more limited with it's hot reload capabilities. It can basically only do method body replacement for a limited set of cases. We are working on expanding the set of edits supported, which is tracked here: dotnet/runtime#57365. You can look at the tracking issue to get an idea of what is current supported and what we're working on adding. Even so the VS error dialog @dodyg is seeing looks wrong. It says there is a compilation error when there isn't one being reported in the output window. If you make an edit that isn't supported by hot reload and you need to rebuild then it should show a different dialog saying precisely that. @Stuart88 Could you please create a VS feedback ticket for that error using the Report a Problem tool in VS? We should investigate what's going on there. It would be great if you could see if the same error dialog is shown with the 17.6 previews. |
That error dialog is not my screenshot.
The currently advertised functionality sounds pretty good to me, and presumably is better on VS 17.6, so perhaps my complaints around hot reload are already resolved. Will give it a test run soon |
Sometimes it also happens when changing only one class="bg-write" for example... it seems that after a long time with vs open it always happens, I close and open VS and it works again. But it's already much better than a few months ago. |
Whoops, my bad. Fixed in my comment. |
@jacksonsfaria what version of VS are you running? |
Microsoft Visual Studio Community 2022 (64 bits) - Versão 17.5.2 |
We landed another wave of Hot Reload improvements in .NET 8 P1 that ships with Visual Studio 2022 v17.6 Preview 2. It'd be great to hear if you still experience recompilation instead of hot-reloads in this version. |
So we need to wait until November for the fixes? Would it be possible to release before then? |
@lonix1 I believe @marek-safar is referring to work we have done for .NET 8 that enables more hot reload capabilities for Blazor WebAssembly apps so that they are on par with what CoreCLR supports. This means that some cases that previously required a rebuild should now work with hot reload. However, this work doesn't address cases where hot reload fails due to unknown errors or doesn't recognize that a change needs to be applied. These later cases are bugs that we expect to patch as soon as we can track down and address the underlying issues. |
Hot reload on ASP.NET Core Preview 3 and Visual Studio 17.6.0 Preview 2.0 works fine with addition of new properties |
Likely fixed by dotnet/sdk#31015. Please file a new issue if the problem persists in .NET 7.0.3xx |
I assume I can't get the 7.0.3xx preview and have to wait a bit? I can't see links for a 7.0.3xx preview anywhere--I can only find for the 8.0 preview. |
8.0.100-preview.3.23178.3 also has the fix. |
OK, thanks, I'm going to wait for the 7.0.3xx SDK to test, as that is what my team will use till .NET 8 release. |
I use a Bootstrap Blazor framework, and my CSS cannot be hot overloaded, it seems to be easily disturbed, After installing. net 8, my blazer project must add
to start, and any hot overloads will fail |
When will 7.0.3xx SDK be released? |
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. As requested, I have piggybacked on the same issue in 7.0.302 at #47836 |
Is there an existing issue for this?
Describe the bug
Please get Hot Reload to work reliably and consistently with Blazor WebAssembly, 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 getwatch : 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.0 and SDK 7.0.100 on a solution that was created with .NET 6 and recently upgraded to 7.When running from VS (with or without debugging), I get similar output:
, or sometimes instead "Your debugged process might be corrupted and restarting it is recommended nearly always."
The most relevant issue seems to be #40587, but there must be much more to that one that isn't working right.
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.".NET Version
7.0.0
Anything else?
dotnet --info
.NET SDK:
Version: 7.0.100
Commit: e12b7af219
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19044
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.100\
Host:
Version: 7.0.0
Architecture: x64
Commit: d099f075e4
.NET SDKs installed:
5.0.408 [C:\Program Files\dotnet\sdk]
6.0.403 [C:\Program Files\dotnet\sdk]
7.0.100 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.25 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.25 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.25 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
The text was updated successfully, but these errors were encountered: