views:

700

answers:

4

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?

A: 

The entries in the .svn directory are not really meant to be accessed directly. I don't know much about what you're doing but I'd suggest you use the mechanism you use to checkout the project to find the HEAD version and path. (I'd actually assume that becuase you are checking out the project you already know the path but maybe that is not so).

Sorry I can't give more information than this.

PintSizedCat
+3  A: 

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" />
Darksider
A: 

I'd recommend you embed svn keywords into your build file as properties. Eg:
<property name="RepositoryPath" value="$HeadURL$" />
<property name="RepositoryVersion" value="$Revision$" />

+2  A: 

This is how I do it for revision number:

<exec
    program="svn"
    commandline='log "${solution.dir}" --xml --limit 1'
    output="${solution.dir}\_revision.xml"
    failonerror="false"/>
<xmlpeek
    file="${solution.dir}\_revision.xml"
    xpath="/log/logentry/@revision"
    property="version.revision"
    failonerror="false"/>
<delete file="${solution.dir}\_revision.xml" failonerror="false"/>
Tim Scott