I couldn't find an option in Visual Studio Whidbey to include the unit test files in the debug build, but exclude them in the release build. I had a look at the .csproj XML, and tried to find some documentation. The ItemGroup element turned out to be the answer. Moving the line
<Compile Include="Tests\TestClass1.cs" />
to a new item block with a condition
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
seemed to work. Looking at the rebuilt assemblies' DLLs using Reflector confirmed that TestClass1 was in the debug version, but not the release version. The Visual Studio project reloaded, but I couldn't see any changes in the configuration pages.