Search code examples
c#.netsvnankhsvn

Getting SVN revision number programmatically (.NET)


I know this question has popped up several times, like here: Getting the subversion repository number into code .

But either it's too complicated for me to understand, or too elaborate for my project. This is my setup in short: Several developers with visual studio 2012 and ankhsvn for connection to our subversion repository, developing a .net web application. A development server synching the latest files from the repository with cruisecontrol.net. A test server, where a specific revision is copied by hand for QA.

The request is to have the latest revision displayed on the site so testers know what version they are looking at.

What is the easiest way? Is there some method of getting it directly from the code (best scenario)? Can cruisecontrol.net do it for me (but that leaves the test server out which is deployed manually). I have searched and searched and many solutions seems so troublesome, i just want to know if there is an easier way before i start building an elaborate contraption.


Solution

  • The revision number can't be obtained "directly from the code" (I assume you mean your code) unless you put it there yourself.

    There are multiple ways you can do it (and the list below is not exhaustive), depending on what your build process looks like and how much work you want to do.

    1. Use the $Revision$ keyword & have the Subversion client CCNet is calling automatically expand it.
    2. Use SubWCRev.exe with some custom code (script) in your build process to insert the value into your file(s).
    3. Use SharpSVN with some custom code (script or EXE) in your build process to insert the value into your file(s).

    Your question is not really specific enough to get into more detail than that. You haven't described what's "troublesome" about the unspecified solutions you've found, and "easiest" is a very subjective measure.