gpt4 book ai didi

c# - 通过 NuGet 提供 App.config 文件

转载 作者:太空宇宙 更新时间:2023-11-03 23:24:55 25 4
gpt4 key购买 nike

我的 nupkg 中有一些信息,我想将其包含在消费者的应用程序中。使用 nupkg 时直接包含部分 app.config 的最佳方法是什么?

我目前已经这样做了:

  • 我的包.nupkg
    • 内容
      • 应用程序配置

但这使得它想要覆盖用户自己的 App.config,而其中可能有有值(value)的信息。

所以我想将我的 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 中?

最佳答案

你这样做using .transform files :

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.

关于c# - 通过 NuGet 提供 App.config 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34156388/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com