rake-dotnet

Rake on my blog, Rake-dotnet on my blog

DESCRIPTION:

rake-dotnet is a library of custom tasks designed to (try to!) make your life as a build-automation author easier.

When have you ever heard of a build-script called anything other than a script? msbuild and nant both try to get you to call them projects. I'll say it up front - the idea of using XML to declaratively define the sequence of hoops one gets the computer to jump through to turn source into packaged software never sat right with me. I looked for something better one day, and found rake. I haven't touched msbuild or nant since, and I've been happier ;-)

Rake-dotnet is a bunch of things that aim at doing the work of creating a featureful build-script, so you don't have to. RDN likes convention-over-configuration. RDN tries to keep the Rakefile (the part YOU have to get involved with) short, because that means you can get on with the business of making software that YOU care about. RDN is designed to try to waste as little of your time as possible (and I'd like to know whether I succeeded, or failed, please ;-) ).

Features

  • Generate AssemblyInfo.cs file(s) for watermarking assemblies with:
    • major.minor.build.svn-revision version number
    • product-name
    • company-name
    • build configuration
  • Build the project files to produce said DLLs (call msbuild against the project file(s))
  • Run XUnit.NET unit tests against said DLLs, and output reports (wrap xunit.console.exe)
  • Run FxCop against said DLLs, and output reports (wrap fxcopcmd.exe)
  • Run NCover against build output to generate coverage metrics
  • Run NCover against coverage to generate coverage reports
  • Harvest build output
  • Package build output as a zip file, naming it like product-name-configuration-vversion.zip

Problems:

  • Relies on a whole bunch of third-party tools and libraries which are too big to distribute within the gem or host myself. So users need to fetch these before they can get up and running. So think of a way to make this more frictionless...

Conventions:

The tasks rely on you following some conventions. These are configurable to some extent, by calling rake to pass in values for the constants.

  • PRODUCT_ROOT defaults to .. - rake's working directory is build/, 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 #{SRC_DIR}/{project-being-built}/bin/{configuration} for class libraries and so forth.

So our source structure looks like:

/
    /3rdparty - contains tools, one directory per tool
    /Foo
        /build
            /Rakefile.rb
        /src
            /Foo.Bar
                /Foo.Bar.csproj
                {files}
        /Foo.sln
    /OtherProduct
        /build
            /Rakefile.rb
        /src
            /OtherProduct.Core
                /OtherProduct.Core.csproj
                {files}
        /OtherProduct.sln

Example: github/presentation/DemoRoot

Roadmap:

(In no particular order)

  • rdoc documentation to supplement blog'd about
  • Support other test-runners - nunit, mbunit, gallio
  • Support other source-controls to get build version number - mercurial, cvs(?), TFS. Or just read it from an environment variable that assumes we're within a CI build.
  • Support changing the conventions to allow users to specify their own source structure
  • Provide an InstallPad for the 3rdparty bits

Requirements:

Install:

  1. gem install rake-dotnet (prepend sudo if you're not on Windows - which doesn't seem likely considering the audience ;-) )
  2. Create a directory to hold 3rdparty dependencies
  3. Fetch the 3rdparty dependencies listed in github/presentation/DemoRoot/3rdparty/readme.txt
    • rake-dotnet uses tools within the paths taken from the default unzip'd location. For example, svn.exe is expected to live within #TOOLS_DIR/svn/bin because that's how svn zip files unzip

Build from source:

  1. gem install rcov rspec diff-lcs (again, prepend sudo if you're not on Windows)
  2. `rake

License:

(The MIT License)

Copyright (c) 2009 Peter Mounce

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.