There is no more "automatic transformations".
The way the configuration work is a bit like "extending" properties in jQuery.
If two parameters in 2 different configuration are made (appsettings.json
and appsettings.Production.json
) then the latter will take precedence
So let's see if we can solve your issue.
Here's what my appsettings.json
would look like:
{
"myValue" : 1
}
And here's what appsettings.Production.json
would look like:
{
"myValue" : 3
}
The first file would be included in your build and would automatically be used by .NET for getting your configuration. So how does it pick up the "Production" one?
Well the answer can be found in the Startup.cs
constructor:
// Set up configuration sources.
var builder = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
Of course, you could potentially pick any variables for your configuration file or load them up directly from the Environment Variables or any other source really.
Side note
The name "environment variable" seem to be that it must set globally for everyone but there's nothing preventing you to set them only for the current process by setting them inline before invoking your script.
So dnx web
will start your application automatically in production on your machine but starting it with Visual Studio (who will automatically set the environment to Development
) will start it in DEV mode.