如何在 nuspec 中指定特定于配置的文件夹

How to specify configuration-specific folder in nuspec

我看到的示例使用相对于 nuspec 文件位置的路径指定要包含的文件,例如:

<file src=".\bin\Debug\SomeFile.dll" target="..." />

有没有一种方法可以根据我的构建配置使用适当的源目录来指定它:即:

TL;DR

使用 $configuration$ 令牌。

完整说明

在 .nuspec 文件 reference 中,在 Replace Tokens 下,它将 $configuration$ 标记定义为:

"Configuration used to build the assembly, defaulting to Debug. Note that to create a package using a Release configuration, you always use -properties Configuration=Release on the command line."

并继续:

Tokens can also be used to resolve paths when you include assembly files and content files. The tokens have the same names as the MSBuild properties, making it possible to select files to be included depending on the current build configuration.

然后以两个例子作为总结:

For example, if you use the following tokens in the .nuspec file:

<files>
    <file src="bin$configuration$$id$.pdb" target="lib\net40\" />
</files>

And you build an assembly whose AssemblyName is LoggingLibrary with the Release configuration in MSBuild, the resulting lines in the .nuspec file in the package is as follows:

<files>
    <file src="bin\Release\LoggingLibrary.pdb" target="lib\net40" />
</files>