Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Teamcity variable replacement in nuspec file

This is my nuspec file to get the package generated from teamcity. The version is actualy set by the teamcity variable.

<?xml version="1.0"?>
<package >
  <metadata>
    <id>Company.Name</id>
    <version>$version$</version>
    <title>Title</title>
    <authors>My Name</authors>
    <owners>We are the owners</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Support</description>
    <releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
    <copyright>Copyright 2013</copyright>
    <tags>Core</tags>
    <dependencies>
        <dependency id="Core.Assembly" version="[1.0.$teamcity.build.id$]" />   
    </dependencies>
  </metadata>
</package>

How would I replace the version with the current teamcity build id number? Tried with both $teamcity.build.id$ and %teamcity.build.id%

This did not work. I tried with $version$ as well. The version gets correctly replaced in the version tag of the package, but not on the dependency.

I want to use the same version of the package that is in the current build, so they have the same build number.

like image 754
Kannaiyan Avatar asked Jun 13 '13 18:06

Kannaiyan


3 Answers

Resolved with AssemblyInfo patcher from Teamcity Build Features.

To fix,

Configuration Steps -> Build Steps -> Add Build Feature (Button)

Add AssemblyInfo Patcher and give the version to 1.0.%teamcity.build.id% and that resolved the problem.

Having the dependent libraries at the version with the $version$ resolved it.

Hope it helps.

like image 132
Kannaiyan Avatar answered Oct 16 '22 02:10

Kannaiyan


You don't need to replace it via TeamCity variables. Use the -version switch, something like:

nuget.exe pack <nuspec> -version %teamcity.build.id%

This way the nuspec version will be overridden at runtime.

like image 41
Manuel Spezzani Avatar answered Oct 16 '22 02:10

Manuel Spezzani


I solved it by simply putting [$version$] in my dependency.

like image 3
Jeff Dunlop Avatar answered Oct 16 '22 03:10

Jeff Dunlop