通过 NuGet 提供 App.config 文件
Supply App.config file via NuGet
我的 nupkg 中有一些信息,我想将其包含在消费者的申请中。使用 nupkg 时直接包含部分 app.config 的最佳方法是什么?
我目前已经这样做了:
- mypackage.nupkg
- 内容
- App.config
但这使得它想要覆盖用户自己的 App.config,而其中可能有有价值的信息。
所以我想将我的 App.config 与用户的 App.config 结合起来。
我已经看到类似这样的内容:C#: manage Multiple App.config files,但我看不出如何强制用户将我的作品包含在其 App.config.
中
我的 App.config 文件的内容:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="somefolder;someotherfolder;" />
</assemblyBinding>
</runtime>
</configuration>
如何强制消费者将我的 App.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.
查看postNuGet Package Transformations这个图解很简单
我的 nupkg 中有一些信息,我想将其包含在消费者的申请中。使用 nupkg 时直接包含部分 app.config 的最佳方法是什么?
我目前已经这样做了:
- mypackage.nupkg
- 内容
- App.config
- 内容
但这使得它想要覆盖用户自己的 App.config,而其中可能有有价值的信息。
所以我想将我的 App.config 与用户的 App.config 结合起来。
我已经看到类似这样的内容:C#: manage Multiple App.config files,但我看不出如何强制用户将我的作品包含在其 App.config.
中我的 App.config 文件的内容:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="somefolder;someotherfolder;" />
</assemblyBinding>
</runtime>
</configuration>
如何强制消费者将我的 App.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.
查看postNuGet Package Transformations这个图解很简单