Including CSHTML files when using dotnet watch

·

1 min read

Everyone has their preferred workflow with .Net 5+ and mine is to use dotnet watch. "watch" is great and it automatically reloads the app whenever it detects a file change. Unfortunately it doesn't detect changes to Razor Views (.cshtml) by default.

To make it monitor these files open up the .csproj file and add the following entry:

<ItemGroup>
    <Watch Include="**\*.cshtml;*.razor;*.js;*.css" Exclude="**\obj\**\*;bin\**\*" />
</ItemGroup>

Now restart dotnet watch and any changes to the cshtml files should now be recognised.