views:

387

answers:

7

There is not an enourmous amount of deployment control where I work at the moment. And while there is a long term plan to create a build script that deals with deployment at the moment we are just publishing our solutions and then copying them to the servers.

It would be very useful to have a text file or soemthing similar that would contain the revision number and branch name to serve as a log of which version is currently running on the live system.

Is it possible to do this using either SVN hooks or a simple post build script in visual studio?

A: 

svnversion is tool for checking current revisions of a working copy.

samuil
A: 

On Windows you have Subwcrev.

Assaf Lavie
thanks for that. Would you be able to provide some more complete code as to how to implement this?
Jack Ryan
A: 

You might be able to do it with a build script. Look at the .svn\entries file in the root of the repository. It should contain the revision number early on in the file (line 5 or so)

Yuliy
A: 

You can use this code get the information from vb. I use a rewritten version of this to find out this information at app startup time.

http://www.codeproject.com/KB/architecture/svn_visual_studio.aspx

+2  A: 

Here is a full breakdown of how I did it

Create a blank text document in the root of your website called Version.txt.

Create a second text document in the root of your website called Version.tmpl with the following contents

Revision:   $WCREV$
Repository: $WCURL$
Modified:   $WCMODS?Yes:No$
Built On:   $WCNOW$

Right click on your website project and choose properties. Then go to the build events tab.

Paste the following into your post build events:

cd $(ProjectDir)
"%ProgramFiles%\TortoiseSVN\bin\SubWCRev.exe" ..\. Version.tmpl Version.txt

This will update the Version.txt file with some details about the working copy, using Version.tmpl as the template. The fact that Version.txt is now included in your website means that every time the website is deployed the Version.txt is also deployed and will contain useful information should you ever need to get your codebase back to the deployed version.

Jack Ryan
A: 

I use ant as my build tool, so I have an ant target that stores the output of svnversion in the file svn-version. That target is a dependency of all the major entry points, so every time I run ant, svn-version is updated. I have the packaging operations include svn-version in all deliverable tar and zip files. So I can always look in svn-version to find out what version of code has been installed.

Whatever build tool you are using, you should be able to do the same. if the data from svnversion isn't sufficient, you may want to add the output of svn info to the file as well.

PanCrit
A: 

I also use Ant and have developed a special Task that is able to retrieve the Subversion information from a local repository (if the code was checked-out) or a remote Subversion server (if the code was exported) and makes them available via regular Ant properties.

Using Ant replacement mechanism (in the Copy task, for example), you can place these values wherever you see fit.

Vladimir