“__built-in-schema.yml (Line: 2012, Col: 24): Expected a mapping” after V2-V3 pipeline conversion

"__built-in-schema.yml (Line: 2012, Col: 24): Expected a mapping" after V2-V3 pipeline converstion

更新:这是 azure_pipelines.yml 的内容:

resources:
  repositories:
  - repository: pf
    type: git
    name: _
    ref: refs/tags/3.6.6
trigger: none

stages:
- template: __
  parameters:
    project:
    - name: "__" # Must be unique within the list of projects
      type: "msbuild" # Used with Publish/Deploy.  Options: adla, dacpac, dotnet, egg, maven, msbuild, node, nuget, python, sap, ssis
      path: "__" # Project Path
      file: "__.csproj" # Project file
      toolset: "msbuild" # Used with Build/Package.  Options: adla, dotnet, maven, msbuild, node, python, sap, ssis
      playbook: "___.yml"
      sonarqube:
        name: scan
        scan: true
        sqExclusions: ""
        additionalProperties: "" #|
#            sonar.branch.name=master
#            sonar.branch.target=master
      fortify: 
        fortifyApp: "_______" 
        fortifyVersion: "____"
        sast: true
        dast: false
      buildConfiguration: $(BuildConfiguration) #release, debug
      buildPlatform: $(BuildPlatform) #any cpu, x86, x64
    - name: "__" # Must be unique within the list of projects
      type: "msbuild" # Used with Publish/Deploy.  Options: adla, dacpac, dotnet, egg, maven, msbuild, node, nuget, python, sap, ssis
      path: "___" # Project Path
      file: "___.csproj" # Project file
      toolset: "msbuild" # Used with Build/Package.  Options: adla, dotnet, maven, msbuild, node, python, sap, ssis
      playbook: "_.yml"
      sonarqube:
        name: scan
        scan: true
        sqExclusions: ""
        additionalProperties: "" #|
#            sonar.branch.name=master
#            sonar.branch.target=master
      fortify: 
        fortifyApp: "______" 
        fortifyVersion: "__"
        sast: true
        dast: false
      buildConfiguration: $(BuildConfiguration) #release, debug
      buildPlatform: $(BuildPlatform) #any cpu, x86, x64

我正在尝试 运行 .NET Framework 4.7 应用程序的 ADO 管道,该应用程序已完成 V2 到 V3 管道转换。我收到以下错误消息,构建甚至没有尝试 运行:

__built-in-schema.yml: Maximum object depth exceeded
__built-in-schema.yml (Line: 2012, Col: 24): Expected a mapping
__built-in-schema.yml: Maximum object depth exceeded

那是在使用 msbuild 工具集。我在解决方案中有一个 API 项目和一个 Web 应用程序项目,所以如果我删除其中一个,然后 运行 管道,它会通过这个阶段,但会因另一个错误而挂起。 (虽然没有必要详细说明该错误,因为它与我删除其他项目直接相关)。

使用 dotnet 工具集,它 运行s,但随后抱怨缺少引用:

> D:\a\s\___\___.csproj(350,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk.1.101\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk.1.101\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" is correct, and that the file exists on disk.
    0 Warning(s)

我尝试在应用程序的 .csproj 文件中注释掉对 Microsoft.WebApplication.targets 的引用,但它只是在我 运行 在本地或通过管道构建时将它们添加回来。

我还尝试将构建池更改为 VS 2017 并使用 VS2019 托管 Windows 2019,认为 VS 目标将在这些池中可用,但运气不好。

我也尝试通过 NuGet 安装 MSBuild.Microsoft.VisualStudio.Web.targets,但结果相同。

我在这里错过了什么?

“__built-in-schema.yml (Line: 2012, Col: 24): Expected a mapping” after V2-V3 pipeline converstion

根据错误日志:

error MSB4019: The imported project "C:\Program Files\dotnet\sdk.1.101\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" was not found

我们可以知道 Microsoft.WebApplication.targets 是从 dotnet SDK 而不是 MSBuild 调用的。 Microsoft.WebApplication.targets 的正确路径应该是:

C:\Program Files (x86)\Microsoft Visual Studio19\Professional\MSBuild\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets

因此,我们需要使用 MSBuild 工具集而不是 dotnet 工具集。并且由于它使用 MSBuild 16.0,我们需要使用构建代理池 Hosted Windows 2019 和 VS2019 来构建项目。

对于错误Maximum object depth exceeded,您的yaml文件的文件路径似乎太深,请尝试缩短文件路径以查看是否可以解决问题。

如果以上信息对您没有帮助,请分享更多关于您问题的信息,例如您的项目类型是什么,是 python 项目吗?并分享您的构建管道 (yaml)。

希望对您有所帮助。