-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
Hello everyone
I have setup a Docker compose file with a custom image to launch ASP.NET Core MVC app with dotnet watch run
.
However, I can't make a browser to auto reload when some code has been changed.
This is because a container does not publish a port number that aspnetcore-browser-refresh.js
use to create a WebSocket connection.
I found that we have ASPNETCORE_AUTO_RELOAD_WS_ENDPOINT
defined in
https://github.com/dotnet/sdk/blob/release/5.0.2xx/src/BuiltInTools/BrowserRefresh/BrowserScriptMiddleware.cs#L23 but setting a value of ASPNETCORE_AUTO_RELOAD_WS_ENDPOINT
environment variable does not change a WebSocket endpoint.
It always get a random port number whenever we run dotnet watch run
and cause me to not be able to configure a published port number in a Docker compose file.
Here is a screenshot of the WebSocket issue.
How to reproduce an issue:
Please follow the instruction in this README https://github.com/codesanook/Codesanook.EFNote#how-to-run-the-project-locally
My development environment
- Windows 10 Pro x64 10.0.19042
- WSL2, Ubuntu 18.04
- Source code in WSL2 directory
- Docker desktop Windows version 20.10.5, build 55c4c88 with
Enable integration with my default WSL distro
- .NET version 5.0.202
- VS Code 1.55.2
- Base image
mcr.microsoft.com/dotnet/sdk:5.0
https://github.com/codesanook/Codesanook.EFNote/blob/main/Dockerfile#L2
Please could you help me figure it out how to make a stick port number of WebSocket in a browser reload script?
Thanks.
Other useful information
- WebSocketScriptInjection.js code
docker-compose down --volumes
to remove a container with its volumes.