dotnet / dotnet/aspnetcore

Hot Reload does not work when running dotnet blazorwasm app in container

Open
#40,473 2 comments 0 reactions 0 assignees View on GitHub
area-commandlinetools docker enhancement feature-hot-reload
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

Hey All, just wanted to ask if this is a known issue or I am doing something wrong as there are not enough resources online.

Here is my Dockerfile

```Dockerfile
ARG REPO=mcr.microsoft.com/dotnet/aspnet
FROM $REPO:6.0.0-preview.7-focal-amd64

ENV \
# Unset ASPNETCORE_URLS from aspnet base image
ASPNETCORE_URLS=http://+:80 \
# Do not generate certificate
DOTNET_GENERATE_ASPNET_CERTIFICATE=false \
# Do not show first run text
DOTNET_NOLOGO=true \
# SDK version
DOTNET_SDK_VERSION=6.0.100-preview.7.21379.14 \
# Enable correct mode for dotnet watch (only mode supported in a container)
DOTNET_USE_POLLING_FILE_WATCHER=true \
# Unset Logging__Console__FormatterName from aspnet base image
Logging__Console__FormatterName= \
# Skip extraction of XML docs - generally not useful within an image/container - helps performance
NUGET_XMLDOC_MODE=skip \
# PowerShell telemetry for docker image usage
POWERSHELL_DISTRIBUTION_CHANNEL=PSDocker-DotnetSDK-Ubuntu-20.04

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
curl \
git \
wget \
&& rm -rf /var/lib/apt/lists/*

# Install .NET SDK
RUN curl -SL --output dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-x64.tar.gz \
&& dotnet_sha512='c8757325407b5eb1e3870f0db87eeaf44df978313c0b2a7f465ec7d0a5647317cba597264ec81577ea0b3bd97bd33d782234392e8e592e073126792a0406df7b' \
&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \
&& mkdir -p /usr/share/dotnet \
&& tar -C /usr/share/dotnet -oxzf dotnet.tar.gz ./packs ./sdk ./sdk-manifests ./templates ./LICENSE.txt ./ThirdPartyNotices.txt \
&& rm dotnet.tar.gz \
# Trigger first run experience by running arbitrary cmd
&& dotnet help

# Install PowerShell global tool
RUN powershell_version=7.2.0-preview.8 \
&& curl -SL --output PowerShell.Linux.x64.$powershell_version.nupkg https://pwshtool.blob.core.windows.net/tool/$powershell_version/PowerShell.Linux.x64.$powershell_version.nupkg \
&& powershell_sha512='cf3b6415fdad38dd582c57b2df06a28528d6243af508626fb20de36116993fd2bb7e73a8869f07b787c73eb920c2559e8a2c2611173a26d2d227d36de08cbc71' \
&& echo "$powershell_sha512 PowerShell.Linux.x64.$powershell_version.nupkg" | sha512sum -c - \
&& mkdir -p /usr/share/powershell \
&& dotnet tool install --add-source / --tool-path /usr/share/powershell --version $powershell_version PowerShell.Linux.x64 \
&& dotnet nuget locals all --clear \
&& rm PowerShell.Linux.x64.$powershell_version.nupkg \
&& ln -s /usr/share/powershell/pwsh /usr/bin/pwsh \
&& chmod 755 /usr/share/powershell/pwsh \
# To reduce image size, remove the copy nupkg that nuget keeps.
&& find /usr/share/powershell -print | grep -i '.*[.]nupkg$' | xargs rm
```

I also added the "hotReloadProfile" : "blazorwasm"
in launchSettings.json, so I get the "Hot Reloading is Enabled" message

I am using the Vscode Remote Container development feature to open a folder in a container. (Default Settings)
created app using
```shell
dotnet new blazorwasm -o MyApp
cd MyApp
dotnet restore
dotnet watch run
```
## Steps:
Try changing a CSS file
## Expected:
Change reflected in UI
## Actual:
no change is seen in the web app, not even after refreshing the page

Edit: Code changes in Razor pages work, but css modifications don't reflect even though this message is printed
```terminal
File changed: /workspaces/Project/Maybe/Shared/MainLayout.razor.css.
watch : Hot reload of scoped css succeeded.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.