2013-03-22 174 views
9
<MSBuild Projects="$(ProjectFile)" Targets="_WPPCopyWebApplication;" 
Properties="OutDir=..\publish;Configuration=Release;Platform=AnyCPU" /> 

我使用上面的脚本来发布Asp.Net项目。在项目设置中,我绝对确保在发布模式下生成调试符号。 MsBuild仍然不会在输出中生成pdb文件。MsBuild在Release配置中不生成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> 
+0

您是如何确保生成调试符号的?你为此设置了哪些设置? – TimVK 2013-03-22 10:23:07

+0

@Syam你好,我有同样的问题。 2件事:自从我切换到vs2012以来,我只是遇到了这种情况,你也是这样吗?更重要的是,我注意到.pdbs *是*生成的,但是它们在构建结束时被删除。这也发生在你身上吗? – bottlenecked 2013-03-22 14:21:55

+0

@TimVK我用vbproj文件的相关信息更新了这个问题 – Syam 2013-03-22 17:39:57

回答

16

看Microsoft.Web.Publishing.targets源之后,我发现了一个变量(ExcludeGeneratedDebugSymbol)被设置为True在Release模式。从评论看来,他们看起来像是想从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 /> 
3

你也可以更新您的个人资料发布(.pubxml)文件,包括属性值。今天我必须用TFS Build 2015中的新版本来做到这一点,让网络发布包含.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>