It’s been quite a while since I said I was going to publish rake-dotnet. In that time, I’ve learned more about making custom tasks for rake, and how to publish a ruby gem (which is ruby’s packaging mechanism). I’ve also implemented some features:

  • AssemblyInfo generation - generate assembly-info files that pull in:

  • product name
  • company name
  • build configuration
  • build date
  • version number (major.minor from a text file; build from an environment variable (or 0 if not build with CI), revision from svn working copy).

This task will overwrite Properties/AssemblyInfo.cs in each project within the source directory, either from a template side-by-side to it, or from the common template in the source directory. If source-control is other than Subversion, revision number is replaced as YYYYMMDD of the current date. If the script is run locally, build-number will not be set (since this environment variable comes from TeamCity, or another build-server).

  • MsBuild compilation - compile projects using MsBuild. Vary the output verbosity and the configuration.
  • Harvest the output to an all-in-one directory, for later packaging for convenience of artifact-publishing to a build server like TeamCity. This enables parallelisation, because we can push out the artifacts to other agents to process their own tasks against (farming out separate test suites or coverage processing, for example).
  • Harvest web-applications to a directory each for later packaging for deployment convenience.
  • Run XUnit.NET fixtures and generate reports
  • Run FxCop and generate a report
  • Run NCover to generate coverage data, and run NCover.Reporting to generate reports off that data (currently, just one report type of many in v3)
  • Package up output for publishing to build-server artifacts. The conventions are set up with a build-server distributed build in mind.
  • All of that in a Rakefile that is currently less than 40 lines long :-)

So; I’ve wrapped up what I’ve done in a ruby gem; you can install it:

  • First get ruby; running the installer with defaults is fine
  • At a command-line: gem install rake-dotnet --include-dependencies (prepend ‘sudo’ if you’re not on Windows).
  • Get a whole bunch of tools - see the gem’s README.txt for details (gems are installed under {ruby}/lib/ruby/gems/{ruby version}/gems/.
  • svn checkout http://my-svn.assembla.com/svn/nrws/trunk/rake_dotnet/lib/DemoRoot to see the demo project.
  • Populate the 3rdparty tools directory (inside DemoRoot) according to the readme.txt within (I plan to make this easier…).
  • Try out the demo by changing into its build directory and running rake from the command-line. rake -T will give you a breakdown of available tasks.

The tasks assume conventions for things like tools-location and solution layout. So until I document those properly with rdoc (on my list of things to learn, right after unit-tests in ruby!), here they are:

  • PRODUCT_ROOT defaults to .. - rake’s working directory isbuild/, where Rakefile.rb is used. All paths are relative to the rake working directory.
  • OUT_DIR defaults to out, hence equivalent to #{PRODUCT_ROOT}/build/out - build-output gets squirted here.
  • SRC_DIR defaults to #{PRODUCT_ROOT}/src - buildable projects should live here (this includes test projects). One directory per project, directory-name matches project-filename matches generated assembly-name.
  • TOOLS_DIR defaults to #{PRODUCT_ROOT}/../3rdparty - intentionally, tools are kept outside of the source tree. This allows for efficient xcopy deployment, or a source-control symbolic link arrangement (svn:externals works well).
  • test projects should have “Tests” somewhere in their project-name.
  • web-application projects should have “Site” somewhere in their project-name.
  • msbuild is assumed to follow its defaults and output into {project-being-built}/bin/{configuration} for class libraries and so forth.
  • Each project directory within SRC_DIR is assumed to have a Properties directory where AssemblyInfo.cs in generated. The template for this file is taken either from a side-by-side AssemblyInfo.cs.template file, or #{SRC_DIR}/AssemblyInfo.cs.template

The Demo solution is set up with these in mind, obviously. They are possible to override to some extent by passing constants via the command-line like rake MSBUILD_VERBOSITY=n CONFIGURATION=Release TOOLS_DIR=../tools.

Source code is available, of course. I have yet to figure out rubyforge for a project home-page and announcements, rdoc for documentation, and ruby unit-tests for ensuring quality. There’s a roadmap in the readme; next major release will be 0.1.0 and will see more in the way of test coverage, nunit support, and more ncover reports (I have to do these within the 21-day trial license, I think…). I am also likely to move the source control to github, since I’ve been wanting to learn git, too…