MsBuild在Release配置中不生成PDB文件

Sya*_*yam 11 msbuild

<MSBuild Projects="$(ProjectFile)"  Targets="_WPPCopyWebApplication;"
Properties="OutDir=..\publish;Configuration=Release;Platform=AnyCPU" />
Run Code Online (Sandbox Code Playgroud)

我使用上面的脚本来发布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>
Run Code Online (Sandbox Code Playgroud)

Sya*_*yam 17

在查看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>
Run Code Online (Sandbox Code Playgroud)

我更新了我的脚本如下.

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