1

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.

EgoPingvina
  • 734
  • 1
  • 10
  • 33

1 Answers1

2

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:

  1. Setup env variable ASPNETCORE_ENVIRONMENT=Staging.
  2. Send enviroment as cli argument when you run the application :" dotnet .\webapi.dll environment=staging
Florent Bunjaku
  • 268
  • 2
  • 7
  • thanks for the answer! What does the first step mean, could you please say how to do it a little bit more? – EgoPingvina Mar 31 '23 at 14:26
  • its not a step (updated the answer sorry for the confusion), you can do one of the approaches. Here you have information for the first approach https://learn.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-7.0#linux – Florent Bunjaku Mar 31 '23 at 14:30
  • The second one helps, thank you so much! – EgoPingvina Mar 31 '23 at 14:41