Azure DevOps YAML Pipeline 失败并显示“未预期序列”

Mar*_*ker 8 c# yaml runtime-error azure-devops azure-pipelines

我一直在尝试在 Azure DevOps(版本 Dev17.M153.3)中创建 YAML 管道。

我创建了一个简单的 Hello World C# 控制台应用程序,并将其签入我们本地托管的 Azure-Git 存储库。我创建了 azure-pipelines.yml 文件,并尝试了其中的各种组合,包括:

  • “.NET 桌面”配置
  • “启动管道”配置
  • 我知道可以使用的另一个 C# 项目中的文件
  • 来自另一个项目的文件,具有各种 mods 来匹配我的测试项目
  • 完全注释掉的文件
  • 一个完全空白的文件

但是,每次我尝试进行构建时,都会收到以下失败消息:

/azure-pipelines.yml(行:1,列:1):意外的序列

鉴于错误总是发生在第 1 行,并且我已经尝试了文件中的许多不同内容,我认为一定是其他内容配置不正确,而不是 YAML 的问题。

请问有人知道我做错了什么吗?各种谷歌搜索都会找到具有类似错误的页面,但没有一个解决方案对我有帮助。


*** 编辑添加各种 YAML 文件尝试:

我目前有一个完全空的 YAML 文件,但仍然收到错误。以前的文件包括:

- task: DotNetCoreCLI@2
  inputs:
    command: 'build'
    projects: '.'

---------------------------------

variables:
  solution: 'HelloWorldCsharpSandpit.sln'

- task: VSBuild@1
  displayName: 'Build solution (debug)'
  inputs:
    solution: '$(solution)'
    vsVersion: 16.0
    platform: x86
    configuration: Debug
    clean: true
  timeoutInMinutes: 10

---------------------------------

# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# [Link removed to avoid odd formatting.]

trigger:
- master

pool:
  name: 'Default'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@0

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'


---------------------------------

# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# https://learn.microsoft.com/azure/devops/pipelines/apps/windows/dot-net
#
#trigger:
#- master
#
#pool:
#  name: 'Default'
#
#variables:
#  solution: '**/*.sln'
#  buildPlatform: 'Any CPU'
#  buildConfiguration: 'Release'
#
#steps:
#- task: NuGetToolInstaller@0
#
#- task: NuGetCommand@2
#  inputs:
#    restoreSolution: '$(solution)'
#
#- task: VSBuild@1
#  inputs:
#    solution: '$(solution)'
#    platform: '$(buildPlatform)'
#    configuration: '$(buildConfiguration)'
#
#- task: VSTest@2
#  inputs:
#    platform: '$(buildPlatform)'
#    configuration: '$(buildConfiguration)'


---------------------------------

# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

steps:
- script: echo Hello, world!
  displayName: 'Run a one-line script'

- script: |
    echo Add other tasks to build, test, and deploy your project.
    echo See https://aka.ms/yaml
  displayName: 'Run a multi-line script'
Run Code Online (Sandbox Code Playgroud)

Krz*_*tof 6

您在这里混合了一些管道。

这是一个:


# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# [Link removed to avoid odd formatting.]

trigger:
- master

pool:
  name: 'Default'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@0

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: VSBuild@1
  displayName: 'Build solution (debug)'
  inputs:
    solution: '$(solution)'
    vsVersion: 16.0
    platform: x86
    configuration: Debug
    clean: true
  timeoutInMinutes: 10
Run Code Online (Sandbox Code Playgroud)

这里另一个但评论道:

---------------------------------

# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# https://learn.microsoft.com/azure/devops/pipelines/apps/windows/dot-net
#
#trigger:
#- master
#
#pool:
#  name: 'Default'
#
#variables:
#  solution: '**/*.sln'
#  buildPlatform: 'Any CPU'
#  buildConfiguration: 'Release'
#
#steps:
#- task: NuGetToolInstaller@0
#
#- task: NuGetCommand@2
#  inputs:
#    restoreSolution: '$(solution)'
#
#- task: VSBuild@1
#  inputs:
#    solution: '$(solution)'
#    platform: '$(buildPlatform)'
#    configuration: '$(buildConfiguration)'
#
#- task: VSTest@2
#  inputs:
#    platform: '$(buildPlatform)'
#    configuration: '$(buildConfiguration)'
Run Code Online (Sandbox Code Playgroud)

再说一遍:


# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

steps:
- script: echo Hello, world!
  displayName: 'Run a one-line script'

- script: |
    echo Add other tasks to build, test, and deploy your project.
    echo See https://aka.ms/yaml
  displayName: 'Run a multi-line script'

Run Code Online (Sandbox Code Playgroud)

如果您在门户上修改管道,则可以使用此按钮进行验证: 在此输入图像描述

如果您的管道一切正常,您将收到反馈。

如果您仍然遇到此问题

  • 从门户中删除您的管道
  • 从存储库中删除您的文件
  • 从门户中的模板开始
  • 运行
  • 根据您在门户上的需要进行调整,并在保存更改之前进行验证