且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过 NuGet 提供 App.config 文件

更新时间:2022-03-11 21:12:28

你这样做 使用 .transform 文件:

在 NuGet 的传统配置文件转换方式中,您将一个文件添加到您的包的内容中,并为其赋予相同的名称要转换的文件,后跟 .transform 扩展名.为了例如,要转换 web.config 文件,您需要创建一个web.config.transform 文件.转换文件包含 XML看起来像一个 web.config 或 app.config 文件,但它只包含需要合并到项目配置文件中的部分.

In NuGet's traditional way of configuration-file transformation, you add a file to your package's content and give it the same name as the file you want to transform, followed by a .transform extension. For example, to transform a web.config file, you create a web.config.transform file. The transformation file contains XML that looks like a web.config or app.config file, but it includes only the sections that need to be merged into the project's configuration file.