2013-03-22 175 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>