从ASP.NET项目中的发布版本中排除页面

Agn*_*ian 7 asp.net release release-management visual-studio-2008 visual-studio

我正在使用"Inspector.aspx"在我的Debug构建中进行一些测试.在发布版本中(更重要的是在创建安装程序时),我手动从项目中排除页面(及其相关的C#文件).

有没有办法自动排除ASP.NET项目中选定的解决方案配置中的文件?

C++项目控制每个配置的每个文件的排除/包含

Jul*_*anM 13

一种选择是编辑msbuild(*.csproj)文件,根据解决方案配置(即调试,发布等)有条件地排除某些文件.例如:

<Compile 
    Exclude="inspector.aspx" 
    Condition="'$(Configuration)' == 'Release'" />
Run Code Online (Sandbox Code Playgroud)

类似地,您可以定义一个ItemGroup,其中只包含您希望包含在Debug构建中的文件:

<ItemGroup Condition="'$(Configuration)' == 'Debug'">
    <Compile Include="inspector.aspx" />
    <Compile Include="...other files..." />
</ItemGroup>
Run Code Online (Sandbox Code Playgroud)