Reputation: 39474
On an ASPNETCORE 1.0 application I have the following on Startup:
public Startup(IHostingEnvironment hostingEnvironment) {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder
.SetBasePath(hostingEnvironment.ContentRootPath)
.AddJsonFile("settings.json", false, true)
.AddJsonFile($"settings.{hostingEnvironment.EnvironmentName}.json", false, true);
builder.AddEnvironmentVariables();
Configuration = builder.Build();
}
I have 2 settings files on my project:
settings.json
settings.production.json
I published the project using the command line:
set ASPNETCORE_ENVIRONMENT=production
dotnet publish --configuration Release
The published files include settings.json
but not settings.production.json
. And settings.json
does include the properties which are only in settings.production.json
. Shouldn't they be merged on publish?
In top of this how to make sure that the application runs on production mode when I copy the files to my server?
Do I need to do anything on Web.config
?
Upvotes: 1
Views: 660
Reputation: 5413
You need to update your project.json
to add your settings.production.json
file to the include
section of publishOptions
:
{
"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"settings.json",
"settings.production.json",
"web.config"
]
}
}
Upvotes: 1