Nodemon for dotnet (dotnet watch)

June 11, 2017

nodemon is used in NodeJS applicatons to automatically reload the application when the source code changes, which allows the next request or app launch to run the latest code. For the .NET developers, we have dotnet-watch. From their github, dotnet-watch is a file watcher for dotnet that restarts the specified application when changes in the source code are detected.

To get started with the dotnet watch tool, simply add the following line to your .csproj file and then run the dotnet restore command.

<ItemGroup>
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.1" />
</ItemGroup>

$ dotnet watch run

If you need to specify file types or folders to include or exclude, simply add a node under an ItemGroup in the .csproj and specify the Watch node's attributes for Include and/or Exclude.

<ItemGroup>
    <!-- extends watching group to include *.js files -->
    <Watch Include="**\*.js" Exclude="node_modules\**\*.js;$(DefaultExcludes)" />
</ItemGroup>

Share

Comments