On my production server, I set the environment variable by adding the following to /etc/environment :
ASPNETCORE_ENVIRONMENT=Production
I checked that it registered with printenv ASPNETCORE_ENVIRONMENT after reboot.
My server is Ubuntu 14.04 and I am using asp.net core 1.1.
Loads my appsettings.Development.json instead of appsettings.Production.json .
This is my startup.cs constructor
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) .AddEnvironmentVariables(); Configuration = builder.Build(); }
Inside my log file, I can correctly see what it says Hosting environment: Production , but if I output the values ββfrom the configuration file for viewing, then these are the values ββfrom the contents of appsettings.Development.json .
I even tried removing appsettings.Development.json from the server and rebooting the entire server, but it still pulls out the same values ββthat I think it should be compiled somewhere.
I also tried adding this to .csproj:
<ItemGroup> <None Include="appsettings.*.json" CopyToPublishDirectory="Always" /> </ItemGroup>
My settings files are displayed inside VS2017 as follows:

By default, appsettings.json has a defualt value for logging; it does not contain the values ββthat I am pulling.
I canβt understand what the problem is.