I want to create multiple appsettings.<environment>.json files in my .NET microservice, and when I run my app I want to specify the environment profiles to use and have them apply the appsettings in the order specified.
For example, i'd like to have appsettings.Development.json to have my default local-development properties for running the app, but I'd also like to have appsettings.Hsqldb.json that would override the DB properties in appsettings.Development.json to be an hsql database.
I've got the following launch.json file in vs Code:
{
"configurations": [
{
"name": "C#: App Debug",
"type": "coreclr",
"request": "launch",
"program": "${workspaceFolder}/API/API.csproj",
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
}
]
}
And what I'd like to do is "ASPNETCORE_ENVIRONMENT": "Development,Hsqldb". Then it would apply the properties in Development first and the Hsqldb properties overtop after. This doesn't seem possible though.
Is it possible to set two environments at the same time? What would be a good way to handle this?
EnvironmentNameenv variable to pass this additional info. Also ordering matters a lot as you will invariably soon find out. So I'd put your appsettings.Hsqldb last but before EnvVariablesASPNETCORE_ENVIRONMENTvariable in conjunction with variousJSONconfiguration files and thelaunchSettings.jsonfile in your project.