Last time we talked about using RAKE instead of NAnt/MSBuild to build .NET projects. Start there if you're curious, or if you missed that episode. I'll wait.
I've recently been helping out a colleague to get his build server up and running for his new project. It has been a major pain. The source code repository is TFS, the build automation tool is MSBuild, and the CI server is Cruise Control .NET. While these three are all decoupled from each other (TFS/TeamBuild, does really like MSBuild, however), its a bit of a pain to configure all of the XML, get plugins in the right place, etc. to get everything to work just right. I've been there, done that myself several times, its doable, but not always the easiest thing to do.
Installing CruiseControl.rb is a breeze, except there is an issue with the latest release when trying to run it on Windows. So instead of downloading it from the website, I would suggest pulling the repository with git, and using that version instead. First, install msysgit.
Then you can execute the following command in your console
git clone git://rubyforge.org/cruisecontrolrb.git
The rest of the steps are pretty simple and straightforward:
cruise add projectname -u https://path.to.your.svn.repo/yourproject/trunkcruise start
That will start up the builder and the dashboard. The dashboard, by default will live on port 3333, so browse to http://yourmachine:3333 to view your dashboard. The path you use above should point to the directory where your RAKE file lives, that will make it easiest for CruiseControl.rb to get it right.
It's pretty dead-simple to configure your project's builder too, you get sample configuration by default in your %USERDIR%/.cruise/projects/projectname/cruise_config.rb that you can modify however you want. Here is what that sample looks like:
# Project-specific configuration for CruiseControl.rb Project.configure do |project| # Send email notifications about broken and fixed builds to email@example.com, firstname.lastname@example.org (default: send to nobody) # project.email_notifier.emails = ['email@example.com', 'firstname.lastname@example.org'] # Set email 'from' field to email@example.com: # project.email_notifier.from = 'firstname.lastname@example.org' # Build the project by invoking rake task 'custom' # project.rake_task = 'custom' # Build the project by invoking shell script "build_my_app.sh". Keep in mind that when the script is invoked, # current working directory is [cruise data]/projects/your_project/work, so if you do not keep build_my_app.sh # in version control, it should be '../build_my_app.sh' instead # project.build_command = 'build_my_app.sh' # Ping Subversion for new revisions every 5 minutes (default: 30 seconds) # project.scheduler.polling_interval = 5.minutes end
Since it is just ruby code, I find that much more appealing than a big nasty XML configuration file, but I guess that's just my opinion.
Hooking it up to TFS
I live in a TFS world at the office, so I have to play by those rules. But I learned from Morpheus that "... rules of a computer system... can be bent. Others can be broken." I'm just bending them.
The SvnBridge provides this rule bending behavior, by letting your subversion clients talk to your TFS repository, thereby allowing CruiseControl.rb to poll against what it thinks is a Subversion repository, but is actually a TFS repository. It's really simple to checkout your TFS repository against it using your favorite SVN repository, so I won't go into it here.
The one thing I wanted to make super simple was putting things in the right place for build outputs. Turns out this is fairly simple after a few minutes with the docs. CruiseControl.rb sets an environment variable telling you where to put things. I abstracted a getter over top of it, so I can conditionally pick a different output location if I'm not inside of a CruiseControl.rb build. It looks like this:
def output_dir if ENV.keys.include?('CC_BUILD_ARTIFACTS') return ENV['CC_BUILD_ARTIFACTS'] else return 'results' end end
As mentioned last time, you can see the latest version of the full RakeFile mentioned above here: http://jonfuller.googlecode.com/svn/trunk/code/CoreLib/RakeFile
I'm feeling some serious CI/Build Automation bliss, hopefully this will get you on your way there too!
If you're used to using something like winmerge with your SCM of choice, if you wind up using TFS, the built-in diff/merge tools can leave much to be desired.
Here is how to change the tool VS 2kX uses to do diffs/merges when hooked up to TFS (note that these are my settings for using winmerge for ALL file types):
Go To: Tools/Options/SourceControl/Visual Studio Team Foundation Server/Configure User Tools
Command: C:\Program Files\WinMerge\WinMergeU.exe
Arguments: /e /wl /dl %6 /dr %7 %1 %2
Command: C:\Program Files\WinMerge\WinMergeU.exe
Arguments: /ub /dl %6 /dr %7 %1 %2 %4
The winmerge command line reference can be found here.
Starting my new project in a new role, as project lead, I need to be managing things in TFS. The UI for batching these things up is nonexistent, but there is Excel integration so you can do it all in Excel, hit save, and it all goes back to the TFS server... pretty slick I must say (I was actually in the midst of writing such a tool when I realized this functionality already existed OOB).
However, the first time I tried to use this functionality... BLAM, I get smacked with this:
TF80042: The document cannot be opened because you do not have Microsoft Excel 2003 or later, or one of its components installed. For more information, see the Team Foundation Installation Guide.
Isn't that teh suck?
Anyways, there is a sweet write-up on how to fix it here: http://blogs.microsoft.co.il/blogs/srlteam/archive/2007/07/17/Error-when-trying-to-export-queries-to-Excel.aspx.