I am sure there are a lot of developers out there who already use Continuous Integration (CI). personally I plan on moving over to a CI environment but I want to dip my toes in the water first to see how the various aspects of CI can work for me. Readers of my previous blog will know that I have already set up Subversion. More recently I have started to use NAnt and in this post I will quickly cover how I set it up to be run from VS 2005.
For those of you who don't know what NAnt is, basically it is an automated build tool. It is run from the command line and reads configuration data from a .build file.
Why use NAnt over Visual Studio?
NAnt doesn't need VS to be running to run a build job, so it can be scheduled to run at any time.
It can automatically check out code from your source control.
It can run any unit tests.
If you have any other files which you want copied over to the build directory, you simply specify them.
Firstly you can get NAnt from here.
Once downloaded, extract it to somewhere on you drive.
I use C:\Program Files\NAnt
In Visual Studio go to Tools >> External Tools then click on Add.
You need to specify the buildfile for NAnt. I keep my build configuration for all projects in a file called nant.build in the root of my project. This way going to Tools >> NAnt will build the project I am currently in without having to pass any other parameter. For arguments, use this.
The build file is actually an XML document where you specify tasks for NAnt. Within this XML are <project> and <target> tags where you specify the tasks.
<project name="myApp" default="build" basedir=".">
<delete dir="nant_build" />
<mkdir dir="nant_build" />
<mkdir dir="nant_build\Docs" />
<mkdir dir="nant_build\Images" />
Add <sources> and <references> for your project like this.
<csc target="exe" output="nant_build\myApp.exe">
<includes name="Web References\webbyservice\Reference.cs"/>
<includes name="myDLL.dll" />
If there are any files you want to copy over to the build directory use the <copy> tag with the todir attribute like this.
<include name="ReadMe.txt" />
Now running Tools >> NAnt will compile your app and copy any additional files to a nant_build directory.
There is so much more to NAnt which I haven't even touched on here. As I explore it more I will blog my findings.
p.s. No I don't actually call my files myClasses,cs or stuff.cs, that is just for an example. Although I did know a developer who had methods called DoStuff().
This is something I have come across during our SQL migration which I didn't even think about. You can zip up your bak files and save considerable hard drive space. We have a 14 gig database which happily compresses down to 2 gig. With hard drives coming down in price, you may think why bother. Well in our migration we have two separate domains for testing purposes which have to stay separate at all costs. Compressing our bak files we can burn it to DVD and move it to the test domain regularly for testing our in house applications.
Right I want this compression automated and complete before I come into the office, so I wrote this small utility.
If you find it at all helpful, feel free to use it. It uses the ICSharpCode.SharpZipLib.Zip library which can be downloaded from here.
static void Main()
ArrayList alFiles = new ArrayList();
DirectoryInfo dir = new DirectoryInfo(".");
foreach (FileInfo f in dir.GetFiles("*.bak"))
for (int i = 0; i < alFiles.Count; i++)
private static void ZipNamedFile(string input)
fileName = input.ToLower();
fileName = fileName.Replace(".bak", ".zip");
using (ZipOutputStream s = new ZipOutputStream(File.Create(fileName)))
s.SetLevel(5); // 0-9, 9 being the highest compression
byte buffer = new byte;
ZipEntry entry = new ZipEntry(Path.GetFileName(input));
entry.DateTime = DateTime.Now;
using (FileStream fs = File.OpenRead(input))
sourceBytes = fs.Read(buffer, 0, buffer.Length);
s.Write(buffer, 0, sourceBytes);
while (sourceBytes > 0);
Well everyone is doing it, so I think I will also. I am going to quickly list my goals I wish to reach for the next six months. I think having goals that are achievable is a good thing, when you have reached that goal you can look back and feel good because you have just improved yourself.
JP Boohdoo has a good posting based around how he wrote down the objectives he wanted to achieve and how he managed to stay focused until he became successful in them. This is just techie stuff, there are a few other more personal things I also wish to achieve, but I won't list them here. Ok so this is what I plan to get myself to 2.0
1. Finish my MCSE Upgrade exams - These have been put on the back-burner for too long, I do not want to loose my certification, and it does come in very handy in my day to day job.
2. Get to grips with the latest development methodologies such as Inversion of Control, Design Patterns, Mocking, Unit testing, MVC and MVP, Dependency Injection, and Continuous Integration
Is there a specific order in which I am best to start with. I already practice unit testing, but as I have had no formal training on the subject I am not entirely sure I am getting the best out of it.
I am only investigating these topics to see what I could implement in the real world. I need to think of a good personal project I could create which will give me the freedom to experiment. I will blog about what I learn, but it may come across as too basic for some of you out there, so I appologise for that.
3. Get all my code up to a standard which will pass an FxCop analysis. I am already part way through this, but as I implement changes and refactorings to working code I am implementing better structure and variable naming.
My book list for the coming few months will be:-
Design Patterns: Elements of Reusable Object-Oriented Software
Code Complete: A Practical Handbook of Software Construction
Refactoring to Patterns
Test Driven Development
The Mythical Man Month and Other Essays on Software Engineering
Well that should keep me busy.
I am not listing too much, I think it would be best achieve many small objectives than be completely overwhelmed.