Skip to content

Provide docs on how to integrate custom msbuild target with dotnet watch and hot reload #39609

@Liero

Description

@Liero

Is your feature request related to a problem? Please describe.

I want my app to do all the compilation in watch mode, when either user start the project from Visual Studio using F5, or from CLI using dotnet watch run.

I don't want to invoke multiple processes from CLI like:

Start-Job { dotnet watch run }; # watch C# changes
Start-Job { dotnet watch /t:YarnBuild }; # watch javascript changes

I have read quite some MS Build and .NET docs recently, but I'm missing more detailed info on how dotnet watch (run/build) works with msbuild.

For example:

  1. how to start custom watch process when when dotnet watch run is invoked, simmilar to Microsoft.TypeScript.MSBuild.

    For example, I have SASS compiler cli `` or custom dotnet tool, that supports watch mode, and I would like it to run together with my dotnet watch run process, so that my SASS files are being compiled incrementally.

  2. how to invoke specific msbuild target when dotnet watch run first builds the project, but not when it does hot reload in watch mode

Additional context

It has been asked couple of times, e.g.:

https://stackoverflow.com/questions/51824979/defining-command-to-be-run-with-dotnet-watch

https://stackoverflow.com/questions/70259508/how-to-integrate-a-watch-process-into-ms-build-and-dotnet-watch-run

It's also a missing part of otherwise nice Microsoft.AspNetCore.ClientAssets package, see
https://devblogs.microsoft.com/dotnet/build-client-web-assets-for-your-razor-class-library/#comment-14441

Metadata

Metadata

Assignees

Labels

area-commandlinetoolsIncludes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPIfeature-hot-reloadThis issue is related to the Hot Reload feaature

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions