Wednesday, August 20, 2008

Small one - SourceSafe via command line

Yes, I haven't been blogging for quite a bit and this small post is not going to change that but at least it is a little somethin'. I've been digging into F# and have had some great learning experience but this is nothing to really present now.

Today I show a little snippet that let's you load some project ("XYZ") from SourceSafe into a specific folder (<Target Directory>). This may come in handy in some sort of automatic build invironment.

At first you need to define, i.e. set as environment variables:
1. SourceSafe User Account, supplied with sufficient privileges to actually access the project you want to retrieve
2. The account's password
3. The path to the SourceSafe DB's SourceSafe configuration file (srcsafe.ini)

Next you ask SourceSafe to change the working directory for the project, you are going to load. You do this via "ss Workfold".
The last step is to load/get the actual project into the working directory.


SET SSUSER=<your SourceSafe Account>
SET SSPWD=<your SourceSafe Account's Password>
SET SSDIR=<the path to your SourceSafe DB>

"SOURCESAFEDIR\ss.exe" Workfold $/<Path to XYZ>/XYZ "<Target Directory>"
"SOURCESAFEDIR\ss.exe" get $/<Path to XYZ>/XYZ -R


The only problem with this solution is, that SourceSafe is going to ask you, whether the intended working folder is the correct one. To fix this we include a change of the current directory into the <Target Directory> and everything will be fine.


SET SSUSER=<your SourceSafe Account>
SET SSPWD=<your SourceSafe Account's Password>
SET SSDIR=<the path to your SourceSafe DB>

cd "<Target Directory>"

"SOURCESAFEDIR\ss.exe" Workfold $/<Path to XYZ>/XYZ "<Target Directory>"
"SOURCESAFEDIR\ss.exe" get $/<Path to XYZ>/XYZ -R


Another way to accomplish this sort of automatic build environment is by the use of SourceSafe initialization variables. These let one configure the SourceSafe environment. By specifying a custom SourceSafe initialization file, one may configure all aspects to one's needs.

No comments: