Hot reload doesn't work in Blazor project in Visual Studio 2022.
If I set a breakpoint and edit code then I get a message:
The source file has change. It no longer matches the version of the file used to build the application being debugged.
and I have to stop and recompile --- like ASPX.
If I start a new Blazor app in Visual Studio, then hot reload works. So it must be something in my project, not the environment.
I see that somehow
<!-- Visual Studio Browser Link --><script type="text/javascript" src="/_vs/browserLink" async="async" id="__browserLink_initializationData" data-requestId="1d...d" data-requestMappingFromServer="false" data-connectUrl="http://localhost:52084/f74...0/browserLink"></script><!-- End Browser Link --><script src="/_framework/aspnetcore-browser-refresh.js"></script></body></html><!--Blazor-Server-Component-State:CfD...9In0=-->is being magically added to the HTML source of every page and the Browser Link Dashboad in Visual Studio shows a connection.
Hot reload is not working in my actual project. My project was started from the same template, and hot reload used to work.
I see that these JS files aren't being added to be HTML source, so I guess that's the problem.
I tried copying these into my App.razor but that made no differenct --- still no conneciton in the Browser Link Dashboard.
My launch profiles are identical:
"https": {"commandName": "Project","dotnetRunMessages": true,"launchBrowser": true,"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}","applicationUrl": "https://localhost:5202;http://localhost:5292","environmentVariables": {"ASPNETCORE_ENVIRONMENT": "Development" } },In both cases my Program.cs has
builder.Services .AddRazorComponents() .AddInteractiveServerComponents() .AddInteractiveWebAssemblyComponents();and app.UseWebAssemblyDebugging(); and both InteractiveServer and InteractiveAuto pages work.
Same result if I run from the command line instead of from Visual Studio:
dotnet watch run --project MyProject\MyProject.csproj --launch-profile httpsAny ideas what to do?