我如何在 NuSpec 文件中创建占位符并通过 TeamCity 参数替换它们

How can i create placeholders in NuSpec file and Replace them via TeamCity parameters

我正在尝试在 Nuspec 中创建 PlaceHolder 并通过 TeamCity 参数替换它们,但 teamcity 无法识别它们。 这是我的 NuSpec 文件元数据

<metadata>
    <id>Id.@environment@</id>
    <title>Title.@environment@</title>
    <version>1.0.0</version>
    <authors>Charles Taylor</authors>
    <owners>Charles Taylor</owners>
    <licenseUrl>http://www.ctcplc.com</licenseUrl>
    <projectUrl>http://www.ctcplc.com</projectUrl>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Currency Request</description>
    <releaseNotes></releaseNotes>
</metadata>

我在 TeamCity 中有一个环境变量。 Team City 在构建过程中崩溃,我无法识别这些值。

我试过将@更改为$,但没有成功。

NuSpec 文件中的一些替换标记是在打包时从程序集中提取的。

为了提供要替换的附加标记值,您可以使用 -Properties 开关,但您必须在 NuSpec 中使用 $token$ 语法文件,而不是@token@

例如

nuget pack -Properties "Environment=DEV;Something=Else"

可以在此处找到更多详细信息 - NuSpec documentation

希望对您有所帮助

更新

如果您添加 NuGet Pack 构建步骤以及高级选项,您应该会看到一个输入字段以输入 TeamCity 中的属性

或者您可以使用命令行参数字段并使用语法 -Properties "Environment=DEV;Something=Else"

在其中输入它们