Thursday, August 26, 2010

Using SVN and Go With Visual Studio For Continuous Integration

Combining Subversion and Go provides a very lightweight and low-cost alternative to Team Foundation Server for continuous integration with Microsoft Visual Studio. Setting this up is easy and takes only a few minutes.

Requirements:

TortoiseSVN integrates elegantly with Windows Explorer. It’s free. We combine this with VisualSVN, a very nice extension for Visual Studio, but this is not required.

Go from ThoughtWorks Studios. The Community Edition is free.

Setting all of this up is straight forward. Just follow the documentation for each. You’re safe with default options across the board.

You have various options for building a Visual Studio solution from Go. The easiest approach is to install Visual Studio on the build machine and configure the Go Pipeline to call devenv.exe using the “Exec” build option in Go. Wrapping the command line execution of devenv in a bat file is advised. For example:

Let’s say you have a solution called MySolution.sln. Create a bat file and call it MyBuild.bat. Put this in the bat file:

"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" -clean
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" C:\Users\me\src\project\MySolution.sln -Build "Release|Any CPU"


A basic Go Pipeline to build this looks like this:

<pipeline name="BuildBlueDiamond">
  <materials>
    <svn url=http://frodo:81/svn/project
username="me" password="me" />
  </materials>
  <stage name="defaultStage">
    <jobs>
      <job name="defaultJob">
        <tasks>
          <exec command="C:\Users\me\src\project\MyBuild.bat" />
        </tasks>
      </job>
    </jobs>
  </stage>
</pipeline>