Different build action for debug and release builds in Visual Studio
See the question and my original answer on StackOverflowTo do this, you'll need to change the .csproj manually, and add a Condition
XML Attribute in the Compile
XML element corresponding to the file you want only in debug builds. Like this:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
...
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
...
</PropertyGroup>
<ItemGroup>
<!-- Add the Condition attribute here, on each of your debug only files
Pick up one of the configuration definition configuration above -->
<Compile Include="DebugOnlyClass1.cs" Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "/>
<!-- normal compilation -->
<Compile Include="Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
...
</Project>