Why does Visual Studio 2019 remove for new .razor files

In Visual Studio Professional 2019 v 16.8, in my Blazor client's .csproj file, I have a line inside an ItemGroup:

<Watch Include="**\*.razor;**\appsettings.*" />

That way, whenever I change a .razor file, dotnet watch run will rebuild and restart the web server automatically. Great.

But now, whenever I create a .razor file in the project (such as Foo.razor), Visual Studio quite unhelpfully adds a "remove" line, such as:

<Watch Remove="Components\Widgets\Foo.razor" />

It also adds this, sometimes:

<Content Remove="Components\Widgets\Foo.razor" />

I then have to manually edit the csproj file to remove these lines. Why is it doing this, and how can I turn it off? Or is there something bigger that is wrong here? Some searching found no one else dealing with this; maybe I have something wrong with my setup?

(I saw exactly the same behavior in earlier versions.) Thanks in advance.

1 answer