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 18.104.22.168. 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:
<assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="Neutral" />
<bindingRedirect oldVersion="22.214.171.124" newVersion="126.96.36.199" />
<bindingRedirect oldVersion="188.8.131.52" newVersion="184.108.40.206" />
Then you need to TELL the NUnit2 NAnt task that you want to use this specific config file:
<formatter type="Plain" />
<test assemblyname="MyProject.Tests.dll" appconfig="mydefaulttest.config" />
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.
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. I am a failed stand-up comic, a cornrower, and a book author.
Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.