Exclude page from release build in ASP.NET project

I use "Inspector.aspx" to run some tests in my Debug assembly. In the Release assembly (and more importantly when creating the installer), I manually exclude the page (and its associated C # files) from the project.

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

C ++ projects allow you to control the exclusion / inclusion of each file on the configuration

+7
visual-studio-2008 visual-studio release release-management
source share
1 answer

One option is to edit the msbuild file (* .csproj) to conditionally exclude certain files based on the solution configuration (for example, Debug, Release, etc.). For example:

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

Similarly, you can define an ItemGroup containing only the files that you want to include in the Debug assembly:

 <ItemGroup Condition="'$(Configuration)' == 'Debug'"> <Compile Include="inspector.aspx" /> <Compile Include="...other files..." /> </ItemGroup> 
+13
source share

All Articles