2

我最近更新了我的一个 nuget 包,因此它现在需要一个应用程序设置出现在消费项目中。我想将 app.config 转换添加到包中,以便任何使用我的包的新版本的人都将使用一些默认值填充此应用程序设置。为此,我按照这篇文章创建了 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>

我还根据这个 stackoverflow 帖子在我的 nuspec 中添加了一行

     <file src="\Content\app.config.install.xdt" target="app.config" />

但是,当我在消费者中安装/更新这个包时,我没有看到这个应用程序设置出现在消费者的 app.config 中。我还缺少其他步骤吗?

4

1 回答 1

6

nuspec 文件条目看起来不正确。它应该是这样的:

 <file src="Content\app.config.install.xdt" target="content" />

您的目标是不正确的 app.config。.xdt 转换需要位于 NuGet 包内的内容目录中。

于 2015-09-10T10:03:52.490 回答