views:

19

answers:

2

I'm using TortoiseSVN and Visual Studio 2008. Is there any way to update my project's subversion with svn's version in every build?

For example, 1.0.0.[svn's version] -> 1.0.0.12

A: 

If you have nant scripts which run the builds, you can do something like this.

The build script will run this line:

svn log c:\yourWorkingDirectory --xml --limit 1

Then it will look at the version # generated in a log file such as

<?xml version="1.0"?>
<log>
<logentry
   revision="12">
<author>someone</author>
<date>2010-08-01T00:00:00</date>
<msg>Last message</msg>
</logentry>
</log>

Here is an example nant script for this:

 <exec
   program="svn.exe"
   commandline='log "${workingCopyDirectory}" --xml --limit 1'
   output="${workingCopyDirectory}\_revision.xml"
   failonerror="false"/>
 <xmlpeek
   file="${workingCopyDirectory}\_revision.xml"
   xpath="/log/logentry/@revision"
   property="svn.revision"
   failonerror="false"/>
 <echo message="Using Subversion revision number: ${svn.revision}"/>

Then update assembly info using that value before using MsBuild

CRice
A: 

TortoiseSVN ships with a tool named SubWCRev. You can use that tool to have it replace keywords in your file(s).

Stefan