Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am trying to create PlaceHolders in Nuspec and Replace them via TeamCity parameters, but teamcity does not recognise them. Here is my NuSpec files Metadata

<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>

I have an environment variable in TeamCity. Team City crashes during build that i can't recognise these values.

I have tried changing @ to $, but no luck.

like image 462
zish Avatar asked Jul 02 '15 10:07

zish


People also ask

What can you do with Nuspec file?

A NUSpec file contains package metadata and is used to create a package. A package is created from your project, which is why it would make sense to place the NUSpec file in the project folder.


1 Answers

Some replacement tokens in a NuSpec file are pulled from the assembly at the point of packaging it.

In order to provide additional token values to be substituted, you can use the -Properties switch, but you must be using the $token$ syntax in your NuSpec file, and not @token@

e.g.

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

More details can be found here - NuSpec documentation

Hope this helps

UPDATE

If you add a NuGet Pack build step and how the advanced options, you should be presented with an input field to enter the properties in TeamCity

enter image description here

Or you can make use of the command line parameters field and enter them there in using the syntax -Properties "Environment=DEV;Something=Else"

like image 106
Evolve Software Ltd Avatar answered Oct 15 '22 07:10

Evolve Software Ltd