views:

361

answers:

1

I am using an "Inspector.aspx" to do some tests in my Debug build. In a Release build (and more importantly when creating an installer), I manually exclude the page (and it's related C# files) from the project.

Is there a way to automatically exclude files in a selected solution configuration in an ASP.NET project?

C++ projects give control on exclusion/inclusion per file per configuration

+6  A: 

One option is to edit your msbuild (*.csproj) file to conditionally exclude certain files based on the Solution Configuration (ie. Debug, Release, etc). For instance:

<Compile 
    Exclude="inspector.aspx" 
    Condition="'$(Configuration)' == 'Release'" />

Similarly you could define an ItemGroup containing only the files that you want to be included in the Debug build:

<ItemGroup Condition="'$(Configuration)' == 'Debug'>
    <Compile Include="inspector.aspx" />
    <Compile Include="...other files..." />
</ItemGroup>
JulianM
I had to do the "reverse" of the first example, and use "Include=" instead of "Exclude=" because it wouldn't compile (VS2008 SP1).
jm
In the latter example, be sure to close the double quotes on Condition
Joel