简体   繁体   中英

Blazor server appsettings files

The Blazor server web site is developed on Windows. The target for publishing is Linux.

After compiling (release) and publishing the release version of the Blazor Server project with MS VS 2019, the publish folder contains (among other files):

appsettings.Development.json

appsettings.json

appsettings.production.json

I wonder, why there is the file appsettings.Development.json. After making a Release build, I would expect having only one *.json file.

Thanks for help.

The JSON Configuration Provider used in the Configuration process on ASP.NET Core is different to the Transformation provider used by web.config files.

The Configuration works with a chain process and the json files are under your control.

Look at this piece of code:

config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
  .AddJsonFile($"appsettings.{env.EnvironmentName}.json", 
  optional: true, reloadOnChange: true);

The configuration provider via the JSON Provider does not apply any transformation for you.

Infos

More information from official Microsoft doc page: https://learn.microsoft.com/en-us/as.net/core/fundamentals/environments?view=as.netcore-5.0

Generally speaking in Visual Studio the system environment variable AS.NETCORE_ENVIRONMENT, during debug session, is set to Development , by default in production is set to Production .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM