.NET 6 Hot Reload triggering rude edit reload on all changes

Viewed 123

I'm currently working on a Blazor Server application using the latest stable release of .NET Core (6.0.302). I have Hot Reload enabled, but the application seems to view any and all changes I made as "rude edits", and will always rebuild the application. This rather defeats the point of using hot reload in the first place, and it appears that what I'm doing is supported. When I create a new test project, hot reload appears to work just fine, so it's not a problem with the SDK from what I can tell, just a problem with my project.

I've updated all NuGet packages, removed old SDKs from my system, tried removing the RazorRuntimeCompilation package from the project to see if it was interfering, all to no avail.

1 Answers

Upon closer inspection of the errors thrown in the console, it would appear that one error was being triggered before the others:

File changed: ./Pages/TND/ScheduleIndex.razor.
dotnet watch: Failed to create MSBuildWorkspace: [Failure] Msbuild failed when processing
the file '<path>\<project>.csproj' with message: <path>\<project>.csproj: (0, 0): 
Package 'Hangfire.Dashboard.Authorization 3.0.0' was restored using '.NETFramework,Version=v4.6.1, 
.NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, 
.NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' 
instead of the project target framework 'net6.0'. This package may not be fully compatible with your project.
dotnet watch: Exited
dotnet watch: Building...

After removal of the offending package, hot reload began working perfectly. It appears that if any warning is thrown from your .csproj file, even if the application builds just fine upon launch, any subsequent hot reloads will fail and trigger a rude-edit-style rebuild of the project.

Related