【问题标题】:How to specify configuration-specific folder in nuspec如何在 nuspec 中指定特定于配置的文件夹
【发布时间】:2016-11-16 09:17:18
【问题描述】:

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

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

有没有办法指定它,它会根据我的构建配置使用适当的源目录:即:

  • bin\Debug 如果我使用 -Prop Configuration=Debug 打包
  • bin\Release 如果我使用 -Prop Configuration=Release 打包

【问题讨论】:

    标签: nuget nuspec


    【解决方案1】:

    TL;DR

    使用$configuration$ 令牌。

    完整说明

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

    "用于构建程序集的配置,默认为Debug。注意 要使用 Release 配置创建包,您总是使用 -properties Configuration=在命令行上发布。"

    然后继续:

    标记也可用于在包含程序集时解析路径 文件和内容文件。令牌与 MSBuild 同名 属性,可以选择要包含的文件 取决于当前的构建配置。

    然后以两个例子结束:

    例如,如果您在 .nuspec 文件中使用以下标记:

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

    然后您构建了一个 AssemblyName 为 LoggingLibrary 的程序集 MSBuild 中的 Release 配置,结果行在 包中的.nuspec文件如下:

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

    【讨论】:

    • 太好了,谢谢。不知道我是如何在文档中错过的,尽管您链接的版本是最新的(2017-7-25)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-10-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-27
    • 2018-05-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多