Visual Studio.NET 2008 + Subversion + NAnt.

I’ve had trouble trying to figure out a way to grab the Subversion revision number in order to populate it into the the auto-generated CommonAssemblyInfo.cs file.

major.minor[.build[.revision]]

Google got me Bryant’s post that linked to Jonathan Malek’s post. Which didn’t help at all because he already migrated his blog to WordPress and the link couldn’t be found. The next link I found worth was Dan Hounshell’s post on the topic. Guess who it refers to? Jonathan’s (now invisible) post.

So finally, I put a few things together and I came up with an almost-done solution, YAY!

<property name=”svnrevision” value=”0″/>
<property name=”svnrevisiontortoise” value=”nothing” />
<if test=”${directory::exists(‘.svn’)}”>

<!–… run the tortoise command line stuff to get latest …–>
<loadfile file=”.svn\all-wcprops” property=”svnrevisiontortoise” failonerror=”false” />
<regex pattern=”ver\/(?’svnrevision’\w+)\/” input=”${svnrevisiontortoise}” failonerror=”false” />

</if>
<echo message=”Using Subversion revision number: ${svnrevision}” />

The only stipulation for this is you HAVE to do an update on the repository before calling running this. I tried running a command, but I don’t have Subversion installed on the machine, so it doesn’t recognize it. Plus, I don’t want to add that dependency. Maybe I can throw it in a bin folder or something as a reference.

<exec program=”svn” commandline=”up” failonerror=”true” output=”svn.update.log.txt” append=”true”/>

Now that I have .revision automatically generated, I’ll need to figure out a simple way to both tag and generate the build number.

One thought on “Visual Studio.NET 2008 + Subversion + NAnt.

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve this: Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.