11
<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>
4

3 回答 3

18

查看 Microsoft.Web.Publishing.targets 源代码后,我发现一个变量 (ExcludeGeneratedDebugSymbol) 在发布模式下设置为 True。从评论来看,他们似乎想从 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 />
于 2013-03-22T17:59:23.970 回答
3

您还可以更新您的发布配置文件 (.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>
于 2015-07-20T13:07:02.823 回答
0

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

<PropertyGroup>
  <ExcludeGeneratedDebugSymbol Condition="$(DebugSymbols) == true">false</ExcludeGeneratedDebugSymbol>
</PropertyGroup>
于 2018-03-27T16:56:40.493 回答