Teamcity variable replacement in nuspec file
Asked Answered
F

4

13

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.

Fold answered 13/6, 2013 at 18:6 Comment(0)
F
13

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.

Fold answered 29/7, 2013 at 19:23 Comment(0)
P
11

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.

Pehlevi answered 28/7, 2013 at 21:50 Comment(1)
Dependent Libraries need to be of the same version. Resolved with Assembly Patcher.Fold
M
3

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

Magniloquent answered 9/12, 2015 at 3:9 Comment(2)
AssemblyInfo Patcher versions your dll as well. Otherwise dll will be on one version and nuget package will be on another version.Fold
This worked for me. The key is to make sure the -Version switch is used on the nuget pack command.Familiarize
D
3

In TeamCity 9.1 You can override the version number in the "Nuget Pack" build step.

enter image description here

Disaffection answered 15/12, 2015 at 19:34 Comment(1)
This may be cumbersome to configure if you want to have same versions across all projects. Means you need to configure for each nuspec instead of one centralized location.Fold

© 2022 - 2024 — McMap. All rights reserved.