When running dotnet watch
or dotnet watch test
, is there a way to know inside of the csproj file that it's running in a watch mode so certain features can be turned on or off?
Asked
Active
Viewed 594 times
1

halfer
- 19,824
- 17
- 99
- 186

Daniel A. White
- 187,200
- 47
- 362
- 445
1 Answers
1
The MSBuild property DotNetWatchBuild
will be set to true
when MSBuild is invoked by dotnet-watch
. Here's some more details on the tool.

Daniel A. White
- 187,200
- 47
- 362
- 445
-
1The file was moved to [`dotnet/sdk` repo](https://github.com/dotnet/sdk/blob/0a71034/src/BuiltInTools/dotnet-watch/README.md). – Jan Joneš Oct 28 '21 at 11:36
-
This is only for the design-time build, not for the actual build: > "dotnet-watch performs a design-time build to find items to watch. When this build is run, dotnet-watch will set the property `DotNetWatchBuild=true`." – Bouke Mar 22 '23 at 07:40