My Issue
I am using Visual Studio Professional 2022 version 17.2.5 and I have a Blazor Server project, targeting .NET 6, where the Hot Reload feature is giving me a headache. This feature works fine in other projects of mine, built entirely the same way.
Problem Description
The Hot Reload feature seems to work only when it comes to c# code-behind. However, in my .razor files, the hot reload does not work. When I make a simple change of text, and hit save, I notice at the bottom of Visual Studio the message:
No code changes were found.
And thus, no Hot Reload. This is not an issue in the other projects of mine, when I make the same changes on them I get the message:
Item(s) Saved
Code changes were applied successfully.
And Hot Reload works as intended.
I want to point out, I expect it to function like it does in my other projects by just clicking save or hitting the Hot Reload button. I don't want to have to use dotnet watch --project run
and then have to wait for it to recompile every single time.
Settings and what I have tried
- I have gone into
Tools > Options > Debugging > .NET / C++ Hot Reload
and made sure all of those settings were checked. - I have compared the
launchSettings.json
files of both projects, they look the same. - I have compared the
Program.cs
files of both projects. Nothing stood out to me that would seem like the cause. - Like I mentioned above, I have tried the
dotnet watch run
approach and this works. It say's Hot Reload enabled, but for any minor changes to take effect the project gets recompiled - I do not want this. - I have been researching my issue over the passed couple weeks but keep coming up empty handed. Most of the answers on SO seem to be either targeted towards Blazor WASM or they are dealing with issues prior to Hot Reload working out of the box in .NET 6. Though maybe I have missed something.
Edit
I have tried running the project with and without the debugger, no difference.
With the suggestion from Scott Perry, I have tried closing VS and deleting the
.vs
,bin
, andobj
folders and then reloading my project. Still nothing.
So, does anyone have any idea what could have gone wrong with this project? Any insight on what I should look into?
Thanks