aspnetcore/src/Tools
Pranav K b34c5ddd5f
Prevent dotnet-watch script injection staleness (#27778)
The browser refresh mechansim used by dotnet-watch and VS modifies HTML content. The modified content includes
a script block that has a WebSocket url that changes for each new execution of dotnet watch run (not rebuilds, but watch itself).
HTML content can come from views or static html files on disk. For the latter, ASP.NET Core participates in browser caching by sending (and invalidating) etag headers.

One way to fix this problem is remove or modify the etag headers. The risk here is that might cause differences in behavior in development users may come to rely on that are unavailable in production. This change instead modifies the HTML content so the output is always consistent and consequently safe to cache. The dynamic content is served separately by the injected middleware.

This change fixes the issue of multiple instances of dotnet-watch. While this issue may crop up if you alternate between dotnet run and dotnet watch run but we haven't seen this being an issue as yet.

Fixes #27548

Summary
Running dotnet watch run multiple times in Blazor WASM apps (or any app that serves static html files) can produce console errors and prevent the browser refresh feature from working. Given that we've been telling our users to use dotnet watch run as their primary way to work outside of VS, it's likely more users would run in this.

Customer impact
A hard browser refresh (Ctrl + R) is needed to get the refresh behavior to work.

Regression
No. This has existed since the feature was introduced we did not get reports of it

Risk
Low. The fix is isolated to dotnet-watch and VS's browser refresh mechanism which is in preview. The change was tested locally, but if there's a regression or if the change interferes with user's workflow, users have the ability to disable this feature.
2020-11-13 14:25:47 -08:00
..
Extensions.ApiDescription.Client
Extensions.ApiDescription.Server Fix MSB4109 (#25880) 2020-09-14 12:07:15 -07:00
FirstRunCertGenerator
GetDocumentInsider
Microsoft.dotnet-openapi
Shared
dotnet-dev-certs
dotnet-getdocument
dotnet-sql-cache [release/5.0] Correct baseline checks (#25227) 2020-08-28 09:53:20 -07:00
dotnet-user-secrets
dotnet-watch Prevent dotnet-watch script injection staleness (#27778) 2020-11-13 14:25:47 -08:00
.vsconfig
Directory.Build.props
Directory.Build.targets [release/5.0] Target 5.0.0 shared framework in global tools (#27599) 2020-11-10 09:46:06 -08:00
README.md
Tools.slnf
build.cmd
build.sh
startvs.cmd

README.md

DotNetTools

Bundled tools

The folder contains command-line tools for ASP.NET Core. The following tools are bundled* in the .NET Core CLI. Follow the links below for more details on each tool.

*This applies to .NET Core CLI 2.1.300-preview2 and up. For earlier versions of the CLI, these tools must be installed separately.

For 2.0 CLI and earlier, see https://github.com/aspnet/DotNetTools/tree/rel/2.0.0/README.md for details.

Non-bundled tools

The following tools are produced by us but not bundled in the .NET Core CLI. They must be aquired independently.

This folder also contains the infrastructure for our partners' service reference features:

Usage

The command line tools can be invoked as a subcommand of dotnet.

dotnet watch
dotnet user-secrets
dotnet sql-cache
dotnet dev-certs
dotnet openapi

Add --help to see more details. For example,

dotnet watch --help