You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/tutorials/dotnet-watch.md
+27-2Lines changed: 27 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,12 +69,26 @@ Any [.NET Core CLI command](/dotnet/core/tools#cli-commands) can be run with `do
69
69
| Command | Command with watch |
70
70
| ---- | ----- |
71
71
| 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 |
74
74
| dotnet test | dotnet watch test |
75
75
76
76
Run `dotnet watch run` in the *WebApp* folder. The console output indicates `watch` has started.
77
77
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
+
78
92
> [!NOTE]
79
93
> 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.
80
94
@@ -178,6 +192,17 @@ dotnet watch msbuild /t:Test
178
192
179
193
VSTest executes when any file changes in either test project.
180
194
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
+
181
206
## `dotnet-watch` in GitHub
182
207
183
208
`dotnet-watch` is part of the GitHub [dotnet/AspNetCore repository](https://github.com/dotnet/AspNetCore/tree/master/src/Tools/dotnet-watch).
0 commit comments