[英]Blazor server appsettings files
The Blazor server web site is developed on Windows. The target for publishing is Linux. Blazor服务器web站点在Windows上开发,发布目标为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):使用 MS VS 2019 编译(发布)并发布 Blazor Server 项目的发布版本后,发布文件夹包含(以及其他文件):
appsettings.Development.json
appsettings.Development.json
appsettings.json
应用程序设置.json
appsettings.production.json
appsettings.production.json
I wonder, why there is the file appsettings.Development.json.我想知道,为什么会有文件appsettings.Development.json。 After making a Release build, I would expect having only one *.json file.
制作发布版本后,我希望只有一个 *.json 文件。
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.在 ASP.NET Core 上的配置过程中使用的JSON Configuration Provider与web.config文件使用的Transformation Provider不同。
The Configuration works with a chain process and the json files are under your control.配置与链式过程一起工作,json 文件在您的控制之下。
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.通过JSON Provider的配置提供程序不会为您应用任何转换。
More information from official Microsoft doc page: https://learn.microsoft.com/en-us/as.net/core/fundamentals/environments?view=as.netcore-5.0更多信息来自 Microsoft 官方文档页面: 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 .一般来说,在 Visual Studio 中,系统环境变量 AS.NETCORE_ENVIRONMENT 在调试 session 期间设置为Development ,默认情况下在生产中设置为Production 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.