svnnantsvn-repository

How do I extract the version and path from an SVN working copy into a nant variable?


I am creating a new build process for a DotNet project which is to be held in Subversion.

For each dll/exe that I compile (via Nant) I would like to include 2 additional attibutes in the dlls that are built.

I already understand the workings of the 'asminfo' nant task. But I need help retrieving the information which I hope to embed in my binaries.

The build will always happen from a full working copy (checked out by the build process itself.) and will therefore always have an .svn directory available.

The attributes I want to add are RepositoryVersion and RepositoryPath. (I understand that these are not the names this information goes by in svn)

In order to do this I will need to extract the RepositoryVersion and RepositoryPath represented by the working copy folder that the BuildFile sits within.

How do I extract this information from any given .svn folder into the 2 nant variables?


Solution

  • Firstly, you can use "svn info --xml >out.xml" to get the svn information to a text file. You can then use a Nant xml-peek to get a value out of the file into a variable.

    <xmlpeek file="out.xml" xpath="/info/entry/url" property="svn.url" />