asp.net 核心中的 web.config 转换流程是什么

What is flow of web.config transformations in asp.net core

在我的应用程序中,我将连接字符串保存在 appsettings.json 中...我没有默认的 web.config 文件。我的目的是学习如何在 asp.net 中管理环境] 核。如果我将进行 web.config 转换,它将自动更改 appsettings.json?

据我所知,web.config不会改变appsettings.json。但是 appsetting.json 包含环境功能。

Asp.net 内核默认启用 JsonConfigurationProvider。

表格official document:

默认的 JsonConfigurationProvider 按以下顺序加载配置:

appsettings.json appsettings.Environment.json : For example, the appsettings.Production.json and appsettings.Development.json files. The environment version of the file is loaded based on the IHostingEnvironment.EnvironmentName. For more information, see Use multiple environments in ASP.NET Core. appsettings.Environment.json values override keys in appsettings.json. For example, by default:

In development, appsettings.Development.json configuration overwrites values found in appsettings.json. In production, appsettings.Production.json configuration overwrites values found in appsettings.json. For example, when deploying the app to Azure. If a configuration value must be guaranteed, see GetValue. The preceding example only reads strings and doesn’t support a default value.

Using the default configuration, the appsettings.json and appsettings.Environment.json files are enabled with reloadOnChange: true. Changes made to the appsettings.json and appsettings.Environment.json file after the app starts are read by the JSON configuration provider.

这意味着如果您使用 web.config 或服务器的环境变量设置环境变量,此提供程序将加载 appsttings.environment.json 的值,这些值将覆盖 appsettings.json 到像旧 web.config.

一样实现转换