I figured I’d tackle a simple project while Matthew sleeps this afternoon: making NAnt 0.8.3 and NUnit 2.1 live happily with one another. Out of the box, this certainly isn’t the case since NAnt 0.8.3 was built against NUnit 2.0.6 and it contains hard references to version 2.0.6 of nunit.framework.dll.
Here’s a set of steps that should make things work:
- Copy
nunit.framework.dllfrom your NUnit 2.1 install directory (typically\Program Files\NUnit V2.1\bin) to your NAnt install directory (mine lives in\Tools\NAnt\bin). - The
RemoteTestRunnerclass has changed between NUnit 2.0 and NUnit 2.1. This requires a change to theNUnit2TestDomain.csfile from the NAnt 0.8.3 distribution. There are references to anInitialize()method, which has been removed in NUnit 2.1. Below is a code frag that shows the new code and the old code. This code frag begins at line 67 ofNUnit2TestDomain.cs:
if (testcase != null) {
runner.TestName = testcase;
runner.TestFileName = assemblyFile;
// runner.Initialize(testcase, assemblyFile);
} else {
runner.TestFileName = assemblyFile;
// runner.Initialize(assemblyFile);
}
- Build NAnt by running “nant” on the command line from the
NAntdirectory.
If you are using Win2K3, and you haven’t installed V1.0 of the frameworks, you’re going to be in for a bit more pain:
- Reset NAnt to use the 1.1 Framework paths. To do this, edit the NAnt.exe.config file (located in
NAnt\bin). Find theframeworksXML element and change thedefaultattribute’s value to “net-1.1”. - When you build NAnt, it will try and run a set of unit tests against the newly built version of NAnt. However, the
NAnt.exe.configfile is created during the build process, and the unit tests will default to using V1.0 of the frameworks. To fix this problem, editNAnt.exe.configin the build directory (Nant\build\nant-0.8.3.50105-debug\binon my machine) and change theframeworksXML element’sdefaultattribute’s value to “net-1.1”. - Re-build NAnt, and the unit tests should all pass.
If you’ve completed the above steps, don’t forget to replace the files in Nant\bin with the files you just compiled!
1 archived reader comment
phil haack (2003-10-06)
I’m just curious if you’ve compared the upcoming MSBuild and/or BuildIT (documented in MS Patterns and Practices book “Team Development with Visual Studio.NET and Visual SourceSafe”) with NAnt.
Right now I’m a big fan of NAnt and I’ve written a custom Fortran Solution task (don’t ask). ;) I’m curious where NAnt will fit in when MS releases MSBuild.