我最近更新了我的一个 nuget 包,现在它需要一个应用程序设置才能出现在消费项目上。我想向程序包添加一个 app.config 转换,以便使用我的程序包新版本的任何人都可以使用一些默认值填充此应用程序设置。为此,我关注了this post。创建 app.config.install.xdt 文件。
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings xdt:Transform="InsertIfMissing">
<add key="CustomSetting" value="CustomValue" />
</appSettings>
</configuration>
我还根据 this stackoverflow post 添加了一行 my nuspec
<file src="\Content\app.config.install.xdt" target="app.config" />
但是,当我在消费者中安装/更新这个包时,我没有看到这个应用程序设置显示在消费者的 app.config 中。我还缺少任何其他步骤吗?
最佳答案
nuspec 文件条目看起来不正确。它应该是这样的:
<file src="Content\app.config.install.xdt" target="content" />
您的目标是不正确的 app.config。 .xdt 转换需要位于 NuGet 包内的内容目录中。
关于c# - 如何在安装/更新 nuget 包时对 app.config 应用 xdt 转换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32486813/