I tried to publish my ASP.NET 5 solution via
dotnet publish -c Release -r ubuntu.18.04-x64 --self-contained false /p:DebugType=None /p:DebugSymbols=false /p:EnvironmentName=Staging
that found here.
But I still see in logs that EnvironmentName
is Production
. What did I do wrong?
I also tried to add
<PropertyGroup Condition=" '$(Configuration)' != '' AND '$(Configuration)' != 'Debug' ">
<EnvironmentName>'$(Configuration)'</EnvironmentName>
</PropertyGroup>
into WebApp .csproj
, but the result is the same - nothing changes.
This approach is valid only if you deploy your application on IIS (docs).
Based on your publish command
dotnet publish -c Release -r ubuntu.18.04-x64 --self-contained false /p:DebugType=None /p:DebugSymbols=false /p:EnvironmentName=Staging
You are building it for ubuntu.18.04-x64, therefore you will not be using IIS. To change the EnvironmentName on Linux you will have to do one of the following:
ASPNETCORE_ENVIRONMENT=Staging
.dotnet .\webapi.dll environment=staging