Two development centers, unit tests that are actually integration tests, which depend on a complex distributed architecture that is far from bullet proof itself, two sets of test systems, two sets of test scripts running the same set of tests, test result reporting in the format of XML files, build process notifications via email, comparing test results manually, failing tests being ignored for weeks, builds breaking, and breaking and breaking… Does this sound familiar? For your sanity sake, I hope not. Continuous Integration CI is the remedy for the software production chaos. This blog post is a starting point into a new software live.
Figure 1: Precision, Timing and repeatability are the foundation for efficient software production.
Reading Martin Fowler’s article about Continuous Integration is the best way to get familiar with the idea.
Continuous Integration has its foundation in automation. That includes compilation, tests and analytics, packaging, staging and deployment. It doesn’t have to be all of theses steps and in most cases it is compilation, tests and analytics. Here is a list of tools that you would need:
TeamCity – Continuous Integration Server
VisualSVNServer – Subversion source control server
Visual Studio 2010 – Integrated Development Environment
VisualSVN – Visual Studio source control integration with SubVersion
Nant – Build scripting runtime
NUnit – .NET unit testing framework
NCover – Code coverage analyzing and reporting tool
ReSharper – Visual Studio coding assistant.
FxCop – Coding style analyzer is part of the Windows SDK
PowerShell – Windows automation environment. Ships on board of Windows 7 and Windows 2008 R2 and can be downloaded here for other versions of Windows.
Tree Surgeon – A little bit out dated, but a good start for getting started with automated builds.
MySQL – Use this if you want your TeamCity server run off a “real” database.
Note: MySQL can be installed and configured by the click of a button, if you are using the Web Platform Installer and select to install WordPress.
The learning resources
The quickest way to get started is to watch some of the DimeCasts.Net web casts. I recommend to start with the Nant ones, if you are new to build automation and build scripts. They tie straight into the screen casts that talk about TeamCity.
Note: There are many great 10 minute screencasts about .NET development on their site. Here is a link to their archive.
Building a Nant Script -- Part 1: Setting up the script
Building a Nant Script -- Part 2: Adding NUnit tests
Building a Nant Script -- Part 3: Adding Code Coverage w/ NCover
Building a Nant Script -- Part 4: Running SQL Scripts w/ SqlCmd
Building a Nant Script -- Part 4: Adding fxCop to your build script
Creating Custom Functions w/ NAnt
Building a NAnt script - Part 5: Adding MSTest results to your build scripts
Learning Nant: Creating Token Driving Configuration Files
Introduction to NDepend, adding NDepend to your Nant Script
Setting up Continuous Integration for your Application with Team City
There is a book about continuous integration with .NET. It is a little big sparse for my taste. It tries to cover too many CI products and only scratches the surface on each.
The title of the book is: Continuous Integration in .NET
The TreeSurgeon CodePlex project comes with a nice set of blog posts that describe some basic build automation concepts.
And of course there is the TeamCity documentation.
The pilot deployment
To get familiar with TeamCity, I am setting up a little sandbox environment. I am using the xmlrpc.net open source project, that is hosted by a subversion server in the cloud. I downloaded and installed TeamCity 6.5 on a Windows 2008 R2 server. This machine also has MySQL installed. I configured TeamCity to use MySQL as database server. I am also using the same machine as a build agent. I have Nant and NUnit installed. Besides that I am using NCover and FxCop to do some code analysis.
My development machine has Visual Studio 2010 SP1, ReSharper 5 and VisualSVN installed.
Note: I am planning on writing a few follow up blog posts that will report about my experience with this setup. Stay tuned. I am already working on one that describes how to switch the TeamCity database to MySQL.
Software building is exiting. Yes! And building successful software is even more exiting. I have a few ideas for augmenting the experience and excitement of Continuous Integration. The first thing that comes to my mind is the integration of TeamCity with WordPress for automatically publishing important news not just to the engineers, but also to the “general” public. Everybody understands blogs. They are chronological, you can navigate by tags, authors and categories. I coined the term LabPress as the name of this application.
Other CI Server products
TeamCity is of course not the only CI product out there. I am also looking at the following three: