SVN checkout using BATCH and PowerShell

Few days back I was working on a script to automate project builds. And at one step I was required to checkout code from source control and build the application. Since everything was done using a single script there was no way I could prompt to user GUI because in this case it was just a plain PowerShell script. After bit to experimenting and Googling, I was able to find a solution that fit my need, but then I thought to use same script as a batch script (of course with some modifications) and I was surprised to see that many commands in PowerShell are declared and used differently then what we normally do in batch script. That was same case with SVN commands.

I use Tortoise SVN for both work and myself, so I am showing this using it. But if you look at help file it is clear that Tortoise SVN is more like a GUI tool not something that can be used via CLI, in fact it is even recommended by author himself to use Official SVN tools instead of Tortoise SVN. But lucky for us, Tortoise SVN already includes official SVN tools !! You can find them at “%ProgramFiles%\TortoiseSVN\bin\”, it includes exes like SVN, SVNAdmin, SVNLook, SVNVersion etc. If they are not there then most likely they are excluded during installation (which is default installation choice). So just grab installation EXE from Tortoise SVN site and run installer again to install these tools.

SVNInstall

 

This quick post is about use of CHECKOUT command in SVN using both PowerShell and Batch Script.

I used below command in PowerShell to checkout specific project with specific version.

$SVNExe = "D:\Program Files\TortoiseSVN\bin\SVN.exe" 
$SVNURL = "https://svnserver/svn/DBackup/trunk/DBackup" 
$CheckOutLocation = "D:\Temp\svnCheckout" 
& $SVNExe checkout -r 23 $SVNURL $CheckOutLocation 

 

But if I try to use same command in Batch script it fails epically (or may be I am doing something wrong). To checkout using Batch script, I have to use following commands.

set SVNExe="D:\Program Files\TortoiseSVN\bin\SVN.exe" 
set SVNURL = "https://svnserver/svn/DBackup/trunk/DBackup" 
set CheckOutLocation = "D:\Temp\svnCheckout" 
%SVNExe% co %SVNURL%@23 %CheckOutLocation%

 

Even SVN Checkout command help also shows that I have to do same as what I am doing in my Batch Script.

svnCheckoutHelp

I am not sure why the difference… or may be I am reading something wrong !!

Anyways, until I find otherwise, I will assume that SVN commands have to be written differently in PowerShell and in Batch Script.

That’s it for now …

It’s Just A Thought … Peace

 

Gaurang Sign

Leave a Reply

Your email address will not be published. Required fields are marked *