A site devoted to discussing techniques that promote quality and ethical practices in software development.

Thursday, May 17, 2007

Using NUnit without installation

I have been using NUnit 2.2.6 for quite some time now and want to upgrade. The fact that I have to remove my NUnit 2.2.6 and install the new version and then to choose which version, .Net 1 or .Net 2, sort of put me off.

Then I came across this discussion thread on the NUnit forum with a lot of recommendations from Charlie Poole, the key developer/architect of NUnit that completely dispelled my concern and worry. It shows how to 'install' NUnit without installation and supporting both versions.

Essentially, you can use NUnit without installation and you can also have NUnit 2.4.1 for .Net 1.1 and .Net 2 co-existing on your machine without conflict.

This is how to do it:
  1. Download from NUnit project on SourceForge the version you want. Let say NUnit 2.4.1 for .Net 1.1. Instead of downloading the msi version, take the ZIP file (not the source). In this case, it will be NUnit-2.4.1-net-1.1.zip
  2. Create a distinct directory for this file, say NUnit-2.4.1-1.1 and unzip the content to it preserving the folder structure.
  3. Create a short-cut on the desktop to bin\NUnit.exe and label it accordingly.
  4. Then go to the Visual Studio Command prompt and in the bin directory run the GacUtil /I to install the nunit.framework.dll to the GAC.
  5. Repeat steps 1-4 for NUnit 2.4.1 for .Net 2 making sure that this version is placeed in a separate directory.
Because the nunit.framework.dll is in the GAC, as Charlie recommends, VS will not perform local copy.

If you have to develop the project at different places, say at work and at home, where the locations of the NUnit are different, then you are recommended to define the location of the NUnit's bin directory to VS project using the "Reference Path" setting.

Reference Path settings are not saved with the csproj file but is in a user file, csproj.user, and this is not source controlled either. Hence moving the csproj around will not require one to change the csproj file.

Now on my work station I have NUnit 2.2.6 so that old projects continue to work and NUnit 2.4.1 for .Net 1 and .Net 2. The only trouble with this arrangement is that your project source control does not contain a version of the nuit.framework.dll.

This blog message explains why there are two versions of NUnit. In fact, one can simply lauch NUnit.exe with the /framework switch instead of changing the .config file.

No comments:

Blog Archive