Passing build number to nant script

I'm having issues trying to get the build number passed to my nant script.

in my nant script I have a property that I am referencing in order to create an assembly file with the version number.

<property name="AssemblyVersion" value="${BUILD_NUMBER}" />

When I try and use this property the value I am getting is ${BUILD_NUMBER} rather than something like 2.1.0.xxxx

I have also tried with ${env.BUILD_NUMBER} and that doesnt work either (get an error rather than the ${BUILD_NUMBER} being written out.

Is there something I am missing here? Or am I doing something stupid?

Thanks in advance


Rich

1 comment
Comment actions Permalink

In case anyone cares or has the same issue, after a lot of experimentation I have found that this works:

<property name="AssemblyVersionUpdater" value="${build.number}"/>

and I am using it like:

  <target name="UpdateVersion">
    <asminfo output="${basedir}\Properties\AssemblyVersionInfo.cs" language="CSharp">
        <imports>
            <import namespace="System" />
            <import namespace="System.Reflection" />
        </imports>
        <attributes>
            <attribute type="AssemblyVersionAttribute" value="${AssemblyVersionUpdater}" />
          <attribute type="AssemblyFileVersionAttribute" value="${AssemblyVersionUpdater}" />
        </attributes>
      </asminfo>
  </target>

This basically creates (overwrites) my AssemblyVersionInfo.cs file (still have an AssemblyInfo.cs file which contains the rest of the info) with the version number from TeamCity.

Rich

0

Please sign in to leave a comment.