【发布时间】:2018-04-05 19:35:28
【问题描述】:
我正在尝试关注these instructions,通过自定义 NuGet 包对目标 App.config 文件执行简单的 XML 转换。
app.config.transform 文件包含以下内容:
<configuration>
<appSetttings>
<add key="foo" value="bar" />
</appSetttings>
</configuration>
.nuspec 文件包含以下内容:
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Foo.Bar</id>
<version>1.0.0</version>
<title>Foo Bar</title>
<authors>Foo</authors>
<description>Bar</description>
</metadata>
<files>
<file src="app.config.transform" target="content" />
</files>
</package>
这会在运行nuget pack 时将文件正确插入到.nupkg 文件中的content 文件夹中。
在 Visual Studio 2017 (15.6.4) 中,将 NuGet 包添加到具有现有 vanilla App.config 文件的全新控制台应用程序时,不会发生任何转换(即App.config 的内容未更改)。 XDT 变换也是如此。
谁能告诉我为什么转型失败了?
更新
我在目标 .NET Framework 4.7.1 项目中使用 PackageReference 作为我的包管理格式。
【问题讨论】:
-
完整要点here
标签: visual-studio nuget nuspec