Azure DevOps-通过VSBuild @ 1启用.pdb文件生成

问题描述

我有一个VSBuild@1任务中使用的pubxml,该构建工作正常,但没有获取.pdb文件。如何确保.pdb文件也包含在我的发行版中?

项目发布配置

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Staging2|Anycpu'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>Anycpu</PlatformTarget>
    <LangVersion>default</LangVersion>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>

Pubxml文件

<Project Toolsversion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <PublishProvider>FileSystem</PublishProvider>
    <LastUsedBuildConfiguration>Staging2</LastUsedBuildConfiguration>
    <LastUsedplatform>Any cpu</LastUsedplatform>
    <SiteUrlToLaunchAfterPublish />
    <LaunchSiteAfterPublish>False</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <publishUrl>Publish</publishUrl>
    <DeleteExistingFiles>True</DeleteExistingFiles>
    <TargetFramework>net472</TargetFramework>
    <DebugSymbols>True</DebugSymbols>
    <DebugType>Full</DebugType>
  </PropertyGroup>
</Project>

YAML构建任务

task: VSBuild@1
  inputs:
    solution: '**\MyApps\Main.csproj'
    msbuildArgs: '/t:build /p:DeployOnBuild=true /p:PublishProfile=publish.pubxml /p:OutputPath=$(build.artifactStagingDirectory)\MainPublish\'
    platform: '$(buildplatform)'
    configuration: '$(buildConfiguration)' 

根据我查看的内容,如果可以设置/Build=full属性,那就很好了。好吧,我的问题是,如果是这样,我应该在哪里添加它?

解决方法

相当于项目文件<DebugType>Full</DebugType>部分的MSBuild参数为:/p:DebugType=full

因此,如果通过添加msbuildArgs来更改VSBuild任务的/p:DebugType=full部分,就可以解决问题。