【问题标题】:MsBuild not generating PDB files in Release configurationMsBuild 没有在发布配置中生成 PDB 文件
【发布时间】:2013-03-22 03:37:46
【问题描述】:
<MSBuild Projects="$(ProjectFile)"  Targets="_WPPCopyWebApplication;"
Properties="OutDir=..\publish;Configuration=Release;Platform=AnyCPU" />

我正在使用上面的脚本来发布 Asp.Net 项目。在项目设置中,我绝对确保在发布模式下生成调试符号。 MsBuild 仍然没有在输出中生成 pdb 文件。

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>Full</DebugType>
    <DefineDebug>false</DefineDebug>
    <DefineTrace>true</DefineTrace>
    <Optimize>true</Optimize>
    <OutputPath>bin\</OutputPath>
    <DocumentationFile>WebProject.xml</DocumentationFile>
    <DebugSymbols>true</DebugSymbols>
  </PropertyGroup>

【问题讨论】:

  • 您是如何确保生成调试符号的?您为此设置了哪些设置?
  • @Syam 你好,我遇到了同样的问题。 2件事:自从我切换到vs2012后,我才遇到这种情况,你也是这种情况吗?更重要的是,我注意到 .pdbs 生成的*,但随后它们在构建结束时被删除。你也有这种情况吗?
  • @TimVK 我已经用 vbproj 文件中的相关信息更新了问题
  • @bottlenecked 是的,我最近切换到 VS 2012。但我在调试配置中构建代码没有这个问题。

标签: msbuild


【解决方案1】:

查看 Microsoft.Web.Publishing.targets 源代码后,我发现一个变量 (ExcludeGeneratedDebugSymbol) 在发布模式下设置为 True。从 cmets 看来,他们想从 WebSite 项目中排除符号,但没有为 WebApplication 项目正确设置条件。

所以,我决定从调用者参数中覆盖我的构建脚本,它就像一个魅力。我还没有确定它可能导致的任何副作用,或者为了未来的稳定性而使用未记录的财产,但它现在有效。

来自 Microsoft.Web.Publishing.target 文件

<!--For website we will always exclude debug symbols from publishing unless it is set explicitly by user in website publish profile-->
    <ExcludeGeneratedDebugSymbol Condition="'$(ExcludeGeneratedDebugSymbol)'=='' And '$(_WebProjectType)' == 'WebSite'">True</ExcludeGeneratedDebugSymbol>

    <ExcludeGeneratedDebugSymbol Condition="'$(ExcludeGeneratedDebugSymbol)'=='' And '$(Configuration)' == 'Release'">True</ExcludeGeneratedDebugSymbol>
    <ExcludeGeneratedDebugSymbol Condition="'$(ExcludeGeneratedDebugSymbol)'==''">False</ExcludeGeneratedDebugSymbol>

我已将我的脚本更新如下。

<MSBuild Projects="$(ProjectFile)"  Targets="_WPPCopyWebApplication;"
Properties="OutDir=..\publish;Configuration=Release;Platform=AnyCPU"; ExcludeGeneratedDebugSymbol=false />

【讨论】:

    【解决方案2】:

    您还可以更新您的发布配置文件 (.pubxml) 以包含该属性值。我今天必须使用 TFS Build 2015 中的新构建位来执行此操作,以使 Web 发布包含 .pdb 文件。查看底部添加属性的文件示例内容。

    <?xml version="1.0" encoding="utf-8"?>
    <!--
    This file is used by the publish/package process of your Web project. You can customize the behavior of this process
    by editing this MSBuild file. In order to learn more about this please visit http://go.microsoft.com/fwlink/?LinkID=208121. 
    -->
    <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <WebPublishMethod>FileSystem</WebPublishMethod>
        <SiteUrlToLaunchAfterPublish />
        <publishUrl>C:\Publish</publishUrl>
        <DeleteExistingFiles>True</DeleteExistingFiles>
        <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
        <LastUsedPlatform>Any CPU</LastUsedPlatform>
        <ExcludeApp_Data>False</ExcludeApp_Data>
        <LaunchSiteAfterPublish>False</LaunchSiteAfterPublish>
        <ExcludeGeneratedDebugSymbol>false</ExcludeGeneratedDebugSymbol>
      </PropertyGroup>
    </Project>
    

    【讨论】:

      【解决方案3】:

      您可以将其直接放入您的*.csproj 文件中,作为最后一个属性组部分(就在Import 元素之前):

      <PropertyGroup>
        <ExcludeGeneratedDebugSymbol Condition="$(DebugSymbols) == true">false</ExcludeGeneratedDebugSymbol>
      </PropertyGroup>
      

      【讨论】:

        猜你喜欢
        • 2010-10-20
        • 2011-07-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-12-11
        相关资源
        最近更新 更多