简体   繁体   English

Blazor 服务器应用程序设置文件

[英]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 Providerweb.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的配置提供程序不会为您应用任何转换。

Infos信息

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.

相关问题 Blazor 和 appsettings.Testing.json - Blazor and appsettings.Testing.json Blazor(服务器端)身份验证和 static 文件 - Blazor (server side) authentication and static files 无法在 NGINX 代理后面的 Blazor 服务器上加载 static 文件 - Can't load static files on Blazor server behind NGINX proxy 如何在 Z4681ZF7FA AppC81259CEF8E959C624DF1D456E5D3297Z 文件(ProjectName.style.css 和 blazor.server.js)中重命名捆绑的 static 文件(ProjectName.style.css 和 blazor.server.js) - How to rename bundled static files(ProjectName.style.css and blazor.server.js) in The Blazor App .net核心sql服务器中的appsettings - appsettings in .net core sql server Blazor WASM wwwroot/appsettings.json 不存在于模板中 - Blazor WASM wwwroot/appsettings.json not present in template 加载不同的 appsettings.json 到 Window object 在 Z98AD8B3C99B3CA16F1F7FA84EE64C44F 中 - Load different appsettings.json into Window object in Blazor WebAssembly 无法在 Blazor WASM 中获取 appsettings.json 的值 - Cannot get the value of appsettings.json in Blazor WASM 根据先前的 appsettings 文件加载自定义 appsettings 文件 - Load a custom appsettings file based on prior appsettings files Blazor 服务器项目 - Blazor Server Project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM