Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nant <version> task

Tags:

c#

.net

nant

How can I use nant tasks to increment build versions? To be more specific how can I link this up with version numbers in assemblyinfo.cs?

like image 915
Brijesh Mishra Avatar asked Dec 04 '22 23:12

Brijesh Mishra


1 Answers

You'll want to consider some sort of system for managing your version increments. One common way to do it is through continuous integration such as CruiseControl.NET. If you go this route, you can use a build target like this:

<target name="set.version" description="generates the version number">
    <echo message="Setting the build version to ${CCNetLabel}..." />
    <attrib file="AssemblyInfo.cs" readonly="false" />
    <asminfo output="AssemblyInfo.cs" language="CSharp">
        <imports>
            <import namespace="System" />
            <import namespace="System.Reflection" />
        </imports>
        <attributes>
            <attribute type="AssemblyVersionAttribute" value="${CCNetLabel}" />
            <attribute type="AssemblyFileVersionAttribute" value="${CCNetLabel}" />
        </attributes>
    </asminfo>
    <attrib file="AssemblyInfo.cs" readonly="true" />
</target>

Where CCNetLabel is a dynamic property that is set from CruiseControl when it executes nant.

like image 155
Saul Dolgin Avatar answered Dec 24 '22 10:12

Saul Dolgin