【问题标题】:Excluding Page from Release Build in ASP.NET Project从 ASP.NET 项目的发布版本中排除页面
【发布时间】:2010-10-12 15:26:31
【问题描述】:

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

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

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

【问题讨论】:

    标签: asp.net visual-studio visual-studio-2008 release release-management


    【解决方案1】:

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

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

    同样,您可以定义一个 ItemGroup,其中仅包含您希望包含在 Debug 构建中的文件:

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

    【讨论】:

    • 我不得不做第一个例子的“逆向”,使用“Include=”而不是“Exclude=”,因为它无法编译(VS2008 SP1)。
    • 在后面的例子中,一定要关闭Condition上的双引号
    • 谢谢乔尔。我现在已经添加了。
    猜你喜欢
    • 2010-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-09
    • 1970-01-01
    • 1970-01-01
    • 2012-06-11
    • 2017-06-08
    相关资源
    最近更新 更多