In a VS2010 solution (not .NET), I want to include the svn version number as part of the application version.
at the moment we do not use make files, but only the settings of the VS / VS project.
I want to get the revision number of the working copy at compile time, save it in a variable so that it can be used later in the code to display the version number.
So far, I have successfully used svnversion to get the latest working copy as a pre-generated event.
"C:\Program Files\CollabNet\Subversion Client\svnversion.exe" -n $(SolutionDir)
During build, I see that the correct version number is returned to the output console.
Now the question is how to store this value in a variable that can be used in code?
I tried to define the variable pre compiler ( _SVNREV ) and use it to save the result from the above cmd, directly from the pre-build event field, but this does not work.
_SVNREV="C:\Program Files\CollabNet\Subversion Client\svnversion.exe" -n $(SolutionDir) %_SVNREV%="C:\Program Files\CollabNet\Subversion Client\svnversion.exe" -n $(SolutionDir) %_SVNREV="C:\Program Files\CollabNet\Subversion Client\svnversion.exe" -n $(SolutionDir) $(_SVNREV)="C:\Program Files\CollabNet\Subversion Client\svnversion.exe" -n $(SolutionDir)
none of them work.
Solution : I have never tried to update a variable from VS env anywhere. so I took another route, calling the script as a pre-build step, which gets the svn revision of the working copy, and then creates a header file with this information.
Here is svnrev.bat for everyone who is interested:
@echo off set cmd="C:\"Program Files\CollabNet\Subversion Client"\svnversion.exe -n %1 " set versionfile=%1/version.h FOR /F %%i IN ('%cmd%') DO SET SVNVER=%%i echo Detected program revision %SVNVER% in %1 echo #pragma once > %versionfile% echo #define _SVNVER "%SVNVER%" >> %versionfile%