Remove NUnit reference for Release build

It sounds like you've got your tests in the same project as your release code. That's not a great idea - split the code into two projects, one with the tests and one with the production code. Only the test project will need to refer to NUnit.

That also means that none of the tests will ship with the release code, and it's easier to browse just the production code or just the test code.


If you prefer to develop with my Unit Tests as a part of the project you're trying to test, you can add the following condition to both your unit test files and your nunit reference in the project file.

Condition=" '$(Configuration)'=='Debug' "

That will only include the nunit reference as well as your test classes in the build when you're in debug mode.

So your project file might have something like this:

<Reference Include="nunit.framework, Version=2.6.3.13283, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" Condition=" '$(Configuration)'=='Debug' ">
  <HintPath>..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
</Reference>

<Compile Include="UnitTests.cs" Condition=" '$(Configuration)'=='Debug' "/>