Skip to content

Commit 28cceb1

Browse files
Update dotnet-watch.md (#19815)
* Update dotnet-watch.md * Update dotnet-watch.md * Update dotnet-watch.md * Update dotnet-watch.md (#19830) * Update dotnet-watch.md * Update dotnet-watch.md * Update dotnet-watch.md * Update mfa.md * Update aspnetcore/tutorials/dotnet-watch.md Co-authored-by: Pranav K <prkrishn@hotmail.com> Co-authored-by: Pranav K <prkrishn@hotmail.com> Co-authored-by: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com>
1 parent 32890f1 commit 28cceb1

1 file changed

Lines changed: 27 additions & 2 deletions

File tree

aspnetcore/tutorials/dotnet-watch.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,26 @@ Any [.NET Core CLI command](/dotnet/core/tools#cli-commands) can be run with `do
6969
| Command | Command with watch |
7070
| ---- | ----- |
7171
| dotnet run | dotnet watch run |
72-
| dotnet run -f netcoreapp2.0 | dotnet watch run -f netcoreapp2.0 |
73-
| dotnet run -f netcoreapp2.0 -- --arg1 | dotnet watch run -f netcoreapp2.0 -- --arg1 |
72+
| dotnet run -f netcoreapp3.1 | dotnet watch run -f netcoreapp3.1 |
73+
| dotnet run -f netcoreapp3.1 -- --arg1 | dotnet watch run -f netcoreapp3.1 -- --arg1 |
7474
| dotnet test | dotnet watch test |
7575

7676
Run `dotnet watch run` in the *WebApp* folder. The console output indicates `watch` has started.
7777

78+
::: moniker range=">= aspnetcore-5.0"
79+
Running `dotnet watch run` on a web app launches a browser that navigates to the app's URL once ready. `dotnet watch` does this by reading the app's console output and waiting for the the ready message displayed by <xref:Microsoft.AspNetCore.WebHost>.
80+
81+
`dotnet watch` refreshes the browser when it detects changes to watched files. To do this, the watch command injects a middleware to the app that modifies HTML responses created by the app. The middleware adds a JavaScript script block to the page that allows `dotnet watch` to instruct the browser to refresh. Currently, changes to all watched files, including static content such as *.html* and *.css* files cause the app to be rebuilt.
82+
83+
`dotnet watch`:
84+
85+
* Only watches files that impact builds by default.
86+
* Any additionally watched files (via configuration) still results in a build taking place.
87+
88+
For more information on configuration, see [dotnet-watch configuration](#dotnet-watch-configuration) in this document
89+
90+
::: moniker-end
91+
7892
> [!NOTE]
7993
> You can use `dotnet watch --project <PROJECT>` to specify a project to watch. For example, running `dotnet watch --project WebApp run` from the root of the sample app will also run and watch the *WebApp* project.
8094

@@ -178,6 +192,17 @@ dotnet watch msbuild /t:Test
178192

179193
VSTest executes when any file changes in either test project.
180194

195+
## dotnet-watch configuration
196+
197+
Some configuration options can be passed to `dotnet watch` through environment variables. The available variables are:
198+
199+
| Setting | Description |
200+
| ------------- | ------------- |
201+
| `DOTNET_USE_POLLING_FILE_WATCHER` | If set to "1" or "true", `dotnet watch` uses a polling file watcher instead of CoreFx's `FileSystemWatcher`. Used when watching files on network shares or Docker mounted volumes. |
202+
| `DOTNET_WATCH_SUPPRESS_MSBUILD_INCREMENTALISM` | By default, `dotnet watch` optimizes the build by avoiding certain operations such as running restore or re-evaluating the set of watched files on every file change. If set to "1" or "true", these optimizations are disabled. |
203+
| `DOTNET_WATCH_SUPPRESS_LAUNCH_BROWSER` | `dotnet watch run` attempts to launch browsers for web apps with `launchBrowser` configured in *launchSettings.json*. If set to "1" or "true", this behavior is suppressed. |
204+
| `DOTNET_WATCH_SUPPRESS_BROWSER_REFRESH` | `dotnet watch run` attempts to refresh browsers when it detects file changes. If set to "1" or "true", this behavior is suppressed. This behavior is also suppressed if `DOTNET_WATCH_SUPPRESS_LAUNCH_BROWSER` is set. |
205+
181206
## `dotnet-watch` in GitHub
182207

183208
`dotnet-watch` is part of the GitHub [dotnet/AspNetCore repository](https://github.com/dotnet/AspNetCore/tree/master/src/Tools/dotnet-watch).

0 commit comments

Comments
 (0)