query
query

Reputation: 381

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.

Upvotes: 2

Views: 1796

Answers (1)

Nicola Biada
Nicola Biada

Reputation: 2800

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/aspnet/core/fundamentals/environments?view=aspnetcore-5.0

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

Upvotes: 2

Related Questions