Getting NAnt 0.85 to get along with NUnit 2.2
This wasn't obvious to Patrick and I, but it is in retrospect. When you're using NAnt's NUnit2 tasks to run NUnit tests, all the assembly versions need to line up. However, sometimes the version of your test framework might not match up with the version that NAnt was built with. For example, you might have tests that were compiled (and, as such, reference) NUnit 2.0.6 or 2.1.4. However, you're using NAnt 0.85 which runs tests with NUnit 188.8.131.52. Not only that, but the NUnit test runner creates a new AppDomain for each test. That means you can't do a binding (version) redirect with a NAnt.exe.config, because the AppDomain gets a funky name of its own and has its own binding redirect rules that the loader follows.
So, you have to create a test.config file. You can name it anything you want, like mydefaulttest.config, and it'll look something like this:
<configuration> ... <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="nunit.framework"
culture="Neutral" /> <bindingRedirect oldVersion="184.108.40.206" newVersion="220.127.116.11" /> <bindingRedirect oldVersion="18.104.22.168" newVersion="22.214.171.124" /> </dependentAssembly> </assemblyBinding> </runtime> ... </configuration>
Then you need to TELL the NUnit2 NAnt task that you want to use this specific config file:
<nunit2> <formatter type="Plain" /> <test assemblyname="MyProject.Tests.dll"
appconfig="mydefaulttest.config" /> </nunit2>
Then the NUnit2 task will make sure the newly created AppDomain uses (or promotes) the correct version and your tests won't fail to load.