Following on from by blog post, Set ASPNETCORE_ENVIRONMENT in web.config using .NET Core CLI. Here's a sample Blazor WebAssembly app that can also take advantage of setting the EnvironmentName parameter at publish time.
Create a new Blazor WebAssembly app using th -ho flag to indicate that the site will be hosted
dotnet new blazorwasm -n EnvironmentNameSample -f net5.0 -ho
This sets up a .Net 5 WebAssembly Solution with 3 projects, the Client, the Server and a Shared project.
From the terminal, run the following command in the folder you're .sln file is in
dotnet publish --configuration Release /p:EnvironmentName=Staging
Once this has completed, inspect the output of the Server/bin/Release/net5.0/publish folder. In here is the generated web.config which includes the ASPNETCORE_ENVIRONMENT value specified in the publish command.
