How to integrate a watch process into MS Build and dotnet watch run

Viewed 138

There are CLI tools (external to .NET) that works in watch mode, e.g: sass --watch or tsc --watch etc.

How do I integrate a custom tool in watch mode into MS Build (.csproj), so that it works with dotnet watch run and hot reload?

Let's take ASP.NET Core as an typical example. I currently invoke the tool on each build instead watch mode

<Project Sdk="Microsoft.NET.Sdk.Web">
  <Target Name="PreBuild" BeforeTargets="PreBuildEvent">
      <!-- How to execute `mycustomtool --watch` ? -->
      <Exec Command="mycustomtool" />
  </Target>  
</Project>
0 Answers
Related