.net 6 blazor wasm hot reload not working - asp.net-core

I'm using Visual Studio 2022 and created a new Blazor webassembly app and ran it.
The option for hot reload on file save is checked.
If I make changes in the Counter component (either HTML or C# code changes) and save the file I see a tick symbol appear at the top left of the browser but neither of the changes have kicked in, the browser just continues with the old version.
After the change the counter still increments even though I changed it to decrement and the h1 title doesnt include the 2 after it.

So i've worked out that it only works if you run the project without debugging, not with debugging.
Ctrl + F5 (hot reload works), F5 (doesn't work)

I can confirm what The Thirsty Ape suggested works when running Visual Studio 2022 and .NET 6
dotnet watch --project .\your-project-name-here.csproj
The browser will launch and the console should display something like:
watch : Hot reload enabled. For a list of supported edits, see https://aka.ms/dotnet/hot-reload. Press "Ctrl + R" to restart.
And finally after making a code change:
watch : Hot reload of changes succeeded.
No refresh is required

Just try restarting Visual Studio, if it suddenly stops working.

I was using the visual studio IDE 2022 v17.0.1
Updated the visual studio IDE 2022 to v17.1.2 supported the blazor hot reload
Note: Help -> Check for updates

It seems that Hot Reload works only in certain configurations:
When I host the app in IIS Express - hot reload works, even in
Debug mode.
When I host the app in Docker, hot reload does NOT work neither
with or without debugger.
I had tested in Visual Studio v17.2.2 (although v17.1.2 should be sufficient)

Another thing to check is that "hot reload on file save" is actually on if like me that's what you rely on.
It can be found in the menu on the flame icon.
I somehow managed to turn that off without knowing and didn't even realize there was a hot reload button.

On Blazor Icon (Next to debug icon) click on hot reload on file save, it should work now.

Related

Theme glitching with newest Version of IntelliJ IDEA

I am using the newest (updated) version of IntelliJ IDEA. I am coding in Javascript (React) and i've been using the One Dark theme for ages now.
But since the last update, everything is glitched.
So first problem:
The IDE is now allways starting in the white theme (which is related to the windows theme)
When i try to change the Theme, either nothing happens, or it just doesnt show any Themes, even tho i installed more than 14 (they are disabled tho).
Second problem:
I can not code in Javascript anymore. There is just no collor at all. No marking for functiond etc.
Third problem:
My IDE is crashing almost everytime, I try to open a new, or existing project.
Why is that, has someone simular issues, and what can i do, to prevent having to reinstall my IDE, as i do not want to set my IDE up again.
Thank you in regards
You will have to reinstall. But you can save the Config file.
So you can keep all your settings.
Here are the Paths for windows
Windows:
Configuration: %APPDATA%\JetBrains\IntelliJIdea2020.3
Plugins: %APPDATA%\JetBrains\IntelliJIdea2020.3\plugins
System: %LOCALAPPDATA%\JetBrains\IntelliJIdea2020.3
Logs: %LOCALAPPDATA%\JetBrains\IntelliJIdea2020.3\log
Hope this helped.

How to enable Blazor hot reload

Having watched Dan Roth's Blazor demo (15 Jan 2020), code changes to a razor file were refreshed to the browser without the stop|build|run cycle. On my VS2019 (latest) I don't get that hot reload. This is a new Blazor SS project from the standard template. Is there a property required to be set to enable it?
I tried
dotnet run watch
but no difference
Edit: 12-04-2021
Initial .NET Hot Reload support
Early support for .NET Hot Reload is now available for ASP.NET Core & Blazor projects using dotnet watch. .NET Hot Reload applies code changes to your running app without restarting it and without losing app state.
To try out hot reload with an existing ASP.NET Core project based on .NET 6, add the "hotReloadProfile": "aspnetcore" property to your launch profile in launchSettings.json. For Blazor WebAssembly projects, use the "blazorwasm" hot reload profile.
Run the project using dotnet watch. The output should indicate that hot reload is enabled:
watch : Hot reload enabled. For a list of supported edits, see https://aka.ms/dotnet/hot-reload. Press "Ctrl + R" to restart.
If at any point you want to force the app to rebuild and restart, you can do so by entering Ctrl+R at the console.
You can now start making edits to your code. As you save code changes, applicable changes are automatically hot reloaded into the running app almost instantaneously. Any app state in the running app is preserved.
OLD ANSWER
This will come in .NET 6 hopefully. But at the time of writing this is still not working yet:

VSTO plugin automacally disable when runing on no debug mode

I'm developing a vsto outlook plugin and works perfectly when I run on debug mode. If I install it, it's always disabled automacally and I can't make it work.
Does anybody knows what's happening or could I do to figure out what's the problem?
We have encountered times when our Chem4Word add in has been hard disabled. This may have caused by pressing the stop button in visual studio during debugging! This makes word think the add in has crashed. In our case it was only apparent when trying to run it as an installed add in, running in visual studio IDE never showed an issue.
See here for instructions on how to clear any hard disabled add ins
https://learn.microsoft.com/en-us/visualstudio/vsto/how-to-re-enable-a-vsto-add-in-that-has-been-disabled?view=vs-2019
I think that this applies to all versions of office.
You can also look in the registry at
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\Word\Resiliency\DisabledItems
Substitute your target application and version number as appropriate.
The key should not have any items if nothing in hard disabled.

InteliJ idea, disable auto build for java, not HTML

https://stackoverflow.com/a/43234019/11369236
I did those and now, when I remove a line of Java code, it automatically restarts debug.
But I do not want this.
When I change HTML, I have to refresh browser also (it does not restart ide, no need of course but I do not want to refresh tab). It does not refresh automatically. But this is not a big problem.
It only should restart HTML (or I can manually restart it) but not for Java or backend files. I could not see such an option.
When I disable "build automatically" (I use the latest version), I have to restart ide to see HTML changes on the browser.
I can not find a way out.

How to enable hot swap in intelliJ

I want to work on intelliJ on my webapps and I don't know how to hot swap code while working.
For example while I was working in Eclipse when I edited jsp files Eclipse automatically, instantly swapped the file so when I refreshed the page my changes were there
When I change class code in Eclipse it worked a bit longer because he republished the app but did it automatically and instantly.
I saw that intelliJ in the runtime configuration has an option 'how class swap'. I did check it but nothing is happening. I had tried compile, make, save and everything else and nothing is happening. I had to reload the app and I had to do dis manually. Secondly intelliJ reloads EVERY application in my webapp directory. I have them a lot so it taking ages. how can I turn on hot swap?
Hotswap only works in debug mode. So you need to connect to your webserver through a debug configuration. Then, after compile either the project or at least the class with the modifications, IntelliJ tries to hotswap that class.
This only works for minor changes. For example, creating new methods on the fly is not possible using this way.
Hotswap works with exploded artifacts on Update action. If it doesn't work with your project, contact support for help and provide the project to reproduce it.