I have ASP.NET Core application (Web Api). The documentation has explained working with multiple environments, however it failed to explain how to set aspnetcore_environment
when publishing the web site.
So lets say if i have 3 environments Development
, Staging
and Production
In classic ASP.NET Web Application i used to create 3 build configurations. Development
, Staging
and Production
( Like shown in picture below). and then 3 .pubxml
files, one for each configuration. Do i need to use the same approach for ASP.NET Core
application as well?
How do i set aspnetcore_environment
in .pubxml
file?
If the approach specified in Question 1 is obsolete, then what's the alternate approach? ( I use Jenkins for CI)
Update 1
I understand that I have to set ASPNETCORE_ENVIRONMENT
however I am not able to understand where do we set this? During development I can set this in profile in launchSettings.json
, however question was how do we set this when publishing to staging or production? do we set environment variable on the target server itself?
Update 2
I found article here that explains different ways of setting environment variable. This partially answered my question. However when I publish the application, the publish process does not honor the environment variable while publishing appsettings.{env.EnvironmentName}.json
I have created separate post for that question
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…