Alexander Beletsky's development blog

My profession is engineering

UppercuT your builds

I like open source tools and frameworks, but more I like open source tools and frameworks that work! There are 2 nice frameworks that I started to use really fast got exactly what I need. They are UppercuT and RoundhousE. I’ve planned to blog about both, but post appears to be quite long, so I’ll spilt it on two.

It is all about build and deployment. I’ve seen different build and deployment system through my career: some domestic made, some commercial, some simple, some complex. I’ve recently started to think about for my own project. But before we started, lets make it clear - what I personally expect from build framework?

  • It have to use a industry standard tools - nant, msbuild, nunit, ncover etc.
  • Build have to be done by one click (press key)
  • During build unit tests have to run
  • During build different code metrics must be collected
  • It have to be integrated with popular SCM systems - svn, git, perforce etc.
  • It must have easy to use versioning system, all build artifacts (binaries, docs) are labeled with one consistent version
  • It must have automatic packaging mechanism, to deploy package on target machine

If you are having database in your application, you should also be concerned of.

  • Versioning of database
  • Deployment of database on any environment
  • Updating live database with new patches

Initially I thought to do some very simple by myself, but later I was browsing some repositories on github and noticed interesting project structure - build/deployment folders as well as number of batch files, like build.bat, test.bat, open.bat etc. I digged a bit and found out that it is actually scaffold provided by UppercuT. After I checked some documentation, I realized that it is probably something that I need! So, please met two projects that would simplify your life a bit: UppercuT - automation build/versioning/packaging; RoundhousE - db migration/versioning/deployment.

UppercuT setup and usage

Just go to UppercuT web site and download latest package. I’ve used 1.0.5.0, in package you will found some docs, that might be interesting to read and framework itself in UppercuT folder.

What’s inside? Well, package contains a configuration files, batch/shell scripts, nant scripts and number of tools - MbUnit, MoMa, NAnt, NCover, NUnit. Internally UppercuT uses nant for build automation. If you are not familiar with nant.build scripts, please don’t worry. UppercuT created in a way, that you very isolated of nant details and perform all configuration only in one place, settings/UppercuT.config - simple XML file.

If you want to apply UppercuT to your existing project, I would recommend to do following steps before you start.

  • Change you folder structure in the way to have on: docs, lib, src on higher level of directories tree.
  • Solution file (.sln) and all projects are put to src folder.
  • All 3rd parties (nunit, moq, ninject etc.) referenced from lib folder.
  • Project documentation moved to docs folder.

As soon as you done, just copy all content of UppercuT folder into your project folder. You are ready to use it. Before actual use you have to configure it. Fortunately, it have to be done only in one place - settings/UppercutT.config file. You have to provide project.name, path_to_solution, repository.path and source_control_type, test.framework and microsoft.framework (net-4.0 is supported).

As you provided all required keys you are able to start build! If you have compliable sources and runnable unit tests, you have to receive SUCCESS build status (I failed to start it at first time, having problems with nunit, please see Issues section below).

Lets see what UppercuT does for us:

  1. It uses source repository to generate _BuildInfo.xml and SolutionVersion.cs files. _BuildInfo.xml contains a digest of build, with revision, version, path to repository, dot-net framework version etc. SolutionVersion.cs is code file that must be referenced from all projects in solution, so they all have a common version.
  2. It compiles all projects in solution.
  3. It runs all unit test in solution (please note, it run only units - projects with *Test* in their names. It does smart job to skip Database, Integration tests).
  4. It copies all db scripts and documentation to build_output folder.
  5. It generates batches for build deployment and db deployment.
  6. It analyzes output binaries with such tools as NCover, NDepend (it is not in package, because it is commercial but if you have it UppercuT will use it), MoMa etc and place results to build_artifacts folder.
  7. It packages everything to code_drop folder, where everything is on right places - web content, binaries, db scripts and build artifacts.

A lot of things for free, right? What more you can do?

  1. You can run open.bat that by default open your Visual Studio with solution.
  2. You can run test.bat to build and re-run unit tests, test.bat all will run all types of tests - units, integration, database. test.bat useful to be run by some Continues Integration servers as CruiseControl.
  3. You can run zip.bat. Very useful feature, that would run build/tests and zip content of code_drop folder into one single zip file (like trackyourtasks.net.v0.1.0.584b2ef4.zip) that could be copied to production system for deployment and placed to repository to track builds.

Issues and criticism

As I said above first time I run build.bat it failed. The reason was that nunit-console loaded 2.0 runtime, but my test assemblies are build with 4.0 framework. It have been solved by modification of build\analyzers\nunit.test.step and adding one additional argument in exec of run_tests target <arg value="/framework=${microsoft.framework}" />. Please check my commit for details. Ferventcoder already contacted me regarding that issue, for I hope in some nearest versions in would be solved :).

Another problem I met with coverage reports generation. It just generates them empy. It is not blame for UppercuT but rather for NCover, that seems to have issues with .NET 4.0. In the same time, somehow, Testdriven.net is able to run NCover with properly generated coverage reports.

No more critic yet. What would be nice to have is already defined tasks for Stylecop and FXCop.

Conclusions

This uppercut turns to be powerfull. If you have no build system yet, UppercuT is recomended.. If you have some “self-written” system that you tired to support - UppercuT is recomended.. If you have build system and happy about it, well.. try UppercuT, you could notice something you missing, or otherwise suggest some new feature for UppercuT :).

Update:

Next blog post is about RoundhousE to handle your database.