views:

149

answers:

3

I want to create a continuous build integration system for .NET using just Windows batch files and Visual Source Safe.

I've come up with the following batch file so far -

set ssdir=\\xxxx\vss
cd d:\mydir
"C:\Program Files\Microsoft Visual SourceSafe\ss.exe" diff "$/sourcedir" -R -Q > diffout.txt

This will spit out a file containg lines like "SourceSafe files different from local files" when a change has been made.

My challenge is to figure out if those lines are in the file, then do a get and kick off MSBuild if they are. I'd then schedule the batch file to run every 10 minutes or so.

Anyone got any thoughts on how to do that? Or any other ways of doing continuous build integration without downloading a complicated build automation system?

Update: Happy to use cscript or powershell too, though not really familiar with those environments. My main aim is to avoid installing 3rd party software

+2  A: 

Writing your own is a good way to learn but I'd suggest that things like maven and cruise control are very simple to get running.

However if dead keen on writing your own, I'd write a filewatcher that watches the files in the VSS Shadow Folders and then kicks off MSBUILD.

Preet Sangha
Good point about trying to write your own as a great learning tool... I did that at one place and am now happily using hudson.
Tim
+2  A: 

cmd.exe is a dinosaur. Here's a PowerShell version.

Set-Alias ss 'C:\Program Files\Microsoft Visual SourceSafe\ss.exe'
Set-Alias msbuild 'C:\Windows\Microsoft.Net\Framework64\v3.5\msbuild.exe'

cd d:\mydir

$diffs = ss diff '$/sourcedir' -R -Q

if ($diffs -match 'SourceSafe files different') {
    msbuild blah
}
Josh Einstein
Excellent Josh - I'll give this a run...
CraigS
One thing I should point out if you're unfamiliar with PowerShell. Be careful when putting $ in strings. I used the single-quote string syntax which doesn't expand variables. If you use double quotes, PowerShell will try to expand variables, for example: $s = 'hello'; write-host "$s world!";
Josh Einstein
I've got this working now - it's sweet. I can even send an email from it. Very nice!
CraigS
Check out PowerShell Community Extensions (http://www.codeplex.com/pscx) for a ton of additional PowerShell functionality.
Josh Einstein
+4  A: 

hudson is not a very complicated thing to get running. Even i managed to get it working in a short amount of time.

And while you're at it, replace sourcesafe...

Tim
Agreed SS should go. I like Team Foundation Server and I'm just one guy. The "reject checkin if build fails" is nice.
Josh Einstein