Tuesday, 12 January 2010

VSS Batch File Apply Patched Files

Below is an example of how I get a base version of my files in VSS and then apply (overwrite) any other files that are in the patch for that version.

My batch file takes 3 arguments:
1. SSDIR
2. Base label
3. Patch label

Here is an example of calling the batch file GetPatch.bat:

"C:\Documents and Settings\shane\Desktop\GetPatch.bat" \\myVSS\Sourcesafe "v0.0.1" "v0.0.1 Patch 4"

Note your label must start with a leter i.e. v0.0.1 in order for the version to be picked up.

Another thing to note is you must go into VSS and click on Tools > Options and then tick the option "Act on projects recursively".

GetPatch.bat
------------

@ECHO OFF
CLS
ECHO Arguments
ECHO =========
ECHO.
ECHO 1. SSIDR: %~1
ECHO 2. Base label: %~2
ECHO 2. Patch label: %~3
ECHO.

IF "%~1"=="" GOTO ArgumentInvalid
IF "%~2"=="" GOTO ArgumentInvalid
IF "%~3"=="" GOTO ArgumentInvalid

SET SSDIR=%~1
ECHO Getting base files for label "%~2". Please be patient this will take a few minutes.
"C:\Program Files\Microsoft Visual SourceSafe\SS.exe" GET $/VSSProject/Project1/*.* -GF -VL"%~2"
ECHO Getting patch files for label "%~3". Please be patient this will take a few minutes.
"C:\Program Files\Microsoft Visual SourceSafe\SS.exe" GET $/VSSProject/Project1/*.* -GF -VL"%~3"

ECHO.
ECHO Done
GOTO Exit

:ArgumentInvalid
ECHO Missing arguments. Not able to continue.

:Exit
ECHO.
PAUSE

No comments: