Well, who doesn’t write tests and do continuous integration (CI) these days? Whether you use one of the many Cruise Control variants, or Team City or some other tool, you most likely get a handy colour coding of builds as either green or red (ie, good, or bad). But, you can take this a step further!
Often on .NET projects, we have a little batch file that we run before checking in (often with a pause at the end so it can be run from a shortcut), to confirm that no tests are broken locally. Well, it’s not much fun peering at the ugly Nant output (or whatever build system you use). Instead, it is quite easy to add a couple of lines to your batch file and change the colour of the console to bright Red or bright Green depending on the success of the local build. It is great for telling what the result was at a glance. I can’t claim credit the idea – it was something we used at EDI for our custom build system, but here’s some batch file code I whipped up which I can claim is all mine, every last GOTO of it! Enjoy 🙂
The following code uses NAnt, but you can replace it with MsBuild or any other build tool that returns a status code.
@echo off color 07 tools\\nant\\NAnt.exe -buildfile:mybuild.build %* IF ERRORLEVEL 1 goto RedBuild IF ERRORLEVEL 0 goto GreenBuild :RedBuild color 4F goto TheEnd :GreenBuild color 2F :TheEnd pause