No manual seems perfectly clear (at least to me) about how production settings can be set. They just talk about how it works, but there is no step-by-step guide. I have done the following:
Attempting to change an environment variable in a project using Guide
I get this error even though the Microsoft Doc explicitly claims to reuse ASPNETCORE_ENVIRONMENT . I can not save these settings

Ignoring this problem, it looks like you can manually create these entries in launchSettings.json , so I:
{ "iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { "applicationUrl": "http://localhost:18549/", "sslPort": 44319 } }, "profiles": { "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, "launchUrl": "api/v10Staff", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", "ASPNETCORE_ENVIRONMENT_T": "Test" } }, "IIS Express (Stage)": { "commandName": "IISExpress", "launchBrowser": true, "launchUrl": "api/v10Staff", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Stage" } }, "ApplicationName": { "commandName": "Project", "launchBrowser": true, "launchUrl": "http://localhost:60000", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", "ASPNETCORE_ENVIRONMENT_T": "Test" } } }
Adding an environment variable to the server
I added an environment variable according to the documentation that I sent to Control Panel > System > Advanced system settings. , and added a new user variable. "ASPNETCORE_ENVIRONMENT" with the value "Stage"
Configuration Using This Guide
The next question I have is that no one shows the "conversion" of appsettings.Stage.json . Does it just make full use of the Stage file over the appsettings file? Is it just necessary to directly indicate what is different? Here we are talking about my files.
appsettings.Stage.json
{ "WebServiceAccount": { "AccountName": "WebUser", "AccountPass": "Wedontcarethatthisishere" }, "ServerLocation": { "ServerName": "http://appss.domain.com:8080", "DBConnection": "server=svAppNameSTG;Max Pool Size=6000;database=ES;Integrated Security=SSPI;MultipleActiveResultSets=True" } }
appsettings.json
{ "WebServiceAccount": { "AccountName": "WebUser", "AccountPass": "testpass1" }, "ServerLocation": { "ServerName": "http://appst.domain.com:8080", "DBConnection": "server=svAppNameTST;Max Pool Size=6000;database=ES;Integrated Security=SSPI;MultipleActiveResultSets=True" } }
I know that the settings and part of the configuration are configured correctly. Because our test environment is working. When I deploy this to our Stage server, I confirmed that it still points to the Test field.
If someone has a guide or you can determine what is wrong with this, that would be great.
For poster
here is the startup constructor
var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) .AddEnvironmentVariables(); Configuration = builder.Build();