I added additional json configuration files to my project
appsettings.DEV.json
appsettings.QA.json
and loaded them into an Startupenvironment dependent function :
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
...
And I understand how to change the environment: change the value of the environment variable ASPNETCORE_ENVIRONMENTin the project properties. However, apparently, it is not possible to specify various environment variables depending on the configuration, the drop-down list is marked as "N / A" and is disabled.
The only option I see is to manually change the value of the environment variable to change which application settings are used. I am sure there is a way to do this automatically, otherwise how would you use CI? (besides using a script to change the environment variable, there should be an easier way).
- : DEV, QA PROD. DEV QA , , , .
