I had this (or something similar) happen to me today when I refactored my blazor single project web app into multiple projects inside the same solution. This is on the latest .NET 7, on a blazor server app.
Whenever I modified any file that would normally work with hot reload, dotnet watch just barfed tons of (invalid) errors and stopped working. Had to ctrl+r to rebuild and then F5 in the browser to keep working. Super annoying.
Going back to a branch before the refactoring made dotnet watch work again.
Anyway, for me it was because one of my csproj files had a bunch of <AdditionalFiles .../>
in it, causing dotnet watch to report them as duplicates when running with --verbose
:
dotnet watch 🚀 Started
dotnet watch ⌚ MSBuildWorkspace warning: [Warning] Duplicate source file 'C:\github\MyApp\SomeFile.razor' in project 'C:\github\MyApp\SomeProject.csproj'
... etc
Removing the entire <ItemGroup>
with all those AdditionalFiles
entries from the .csproj file solved the problem for me.