Bite my bytes

What I learn by day I blog at night - A blog from Microsoft Consultant working from Ljubljana, Slovenia

  Home :: Contact :: Syndication  
  999 Posts :: 7691 Comments :: 235 Trackbacks


Most popular posts
in last 90 days


My Projects



Copyright © by David Vidmar
Contact me!
LinkedIn Profile

At my previous job I have implemented the versioning of our product through separate C# program which I called from NAnt script. It worked but the solution was so clean as I like them to be. Second time I tried to solve same problem I decided to do it just with NAnt. Some C# code inside .build file should do the trick. And it did….

Google provided some nice code from Joshua's .Net Tips. The code is nice and really well described so it would be a shame to try and do it once again although I did change the code a bit.

He provides four NAnt sub-targets:

  • getversion for reading a version number from version.txt file,
  • setversionstring for setting NAnt property with the version number,
  • incrementbuildnumber for incrementing the version number in text file and
  • setversion – for setting the version numbers in AssemblyInfo files.

I had implemented this on three different projects, one on Subversion and two on SourceSafe. The Subversion part is easy, you just call tasks getversion, incrementbuildnumber and then setversion. But on SourceSafe I had to implement checkout and check-in of files in incrementbuildnumber for version.txt and in setversion for all files. I have used vsscheckout and vsscheckin tasks of NAntContrib (which also published 0.85 to sync with NAnt)

My other modification includes:

  • a property to set filter for searching AssemblyInfo files – a small change in setversion. I just set the version.filter property and <call> a task.  
  • I also change the value of build.version.filename so I can have multiple version numbers for seperate projects. I use it with filter mentioned above
  • I addded and <echo message=”${filename}”> so I can easily debug wich file failed to checkout from SourceSafe.

Here is a snippet of modified code:

 <target name="setversion" description="Stamp the version info onto assemblyinfo.cs files">
  <foreach item="File" property="filename">
    <items basedir="application">
     <include name="**\${version.filter}\AssemblyInfo.cs"></include>
<echo message=”${filename}”>
   … continued

Posted on Wednesday, October 18, 2006 11:53 PM | Filed under: Developement |
Comments have been closed on this topic.