Azure DevOps YAML 管道失败并显示 "A sequence was not expected"
Azure DevOps YAML Pipeline fails with "A sequence was not expected"
我一直在尝试在 Azure DevOps(版本 Dev17.M153.3)中创建 YAML 管道。
我创建了一个简单的 Hello World C# 控制台应用程序并将其签入我们本地托管的 Azure-Git 存储库。我创建了我的 azure-pipelines.yml 文件并尝试了其中的各种组合,包括:
- “.NET 桌面”配置
- “入门管道”配置
- 来自另一个我知道有效的 C# 项目的文件
- 来自另一个项目的文件,带有各种 mod 以匹配我的测试项目
- 完全注释掉的文件
- 一个完全空白的文件
但是,每次尝试构建时,我都会收到以下失败消息:
/azure-pipelines.yml (Line: 1, Col: 1): A sequence was not expected
鉴于错误总是出现在第 1 行并且我在文件中尝试了很多不同的内容,我认为一定是其他配置不正确,而不是 YAML 的问题。
有人知道我做错了什么吗?
各种 Google 搜索找到具有类似错误的页面,但 none 的解决方案帮助了我。
*** 编辑以添加各种 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://docs.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'
您在这里混合了几个管道。
这是一个:
# .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
这里还有一个评论:
---------------------------------
# .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://docs.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'
如果您在门户网站上修改管道,您可以使用此按钮进行验证:
如果您的管道一切正常,您将收到反馈。
如果您仍然遇到此问题
- 从门户中删除您的管道
- 从存储库中删除您的文件
- 从门户网站的模板开始
- 运行它
- 在门户上根据您的需要进行调整并在保存更改前进行验证
我一直在尝试在 Azure DevOps(版本 Dev17.M153.3)中创建 YAML 管道。
我创建了一个简单的 Hello World C# 控制台应用程序并将其签入我们本地托管的 Azure-Git 存储库。我创建了我的 azure-pipelines.yml 文件并尝试了其中的各种组合,包括:
- “.NET 桌面”配置
- “入门管道”配置
- 来自另一个我知道有效的 C# 项目的文件
- 来自另一个项目的文件,带有各种 mod 以匹配我的测试项目
- 完全注释掉的文件
- 一个完全空白的文件
但是,每次尝试构建时,我都会收到以下失败消息:
/azure-pipelines.yml (Line: 1, Col: 1): A sequence was not expected
鉴于错误总是出现在第 1 行并且我在文件中尝试了很多不同的内容,我认为一定是其他配置不正确,而不是 YAML 的问题。
有人知道我做错了什么吗? 各种 Google 搜索找到具有类似错误的页面,但 none 的解决方案帮助了我。
*** 编辑以添加各种 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://docs.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'
您在这里混合了几个管道。
这是一个:
# .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
这里还有一个评论:
---------------------------------
# .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://docs.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'
如果您在门户网站上修改管道,您可以使用此按钮进行验证:
如果您的管道一切正常,您将收到反馈。
如果您仍然遇到此问题
- 从门户中删除您的管道
- 从存储库中删除您的文件
- 从门户网站的模板开始
- 运行它
- 在门户上根据您的需要进行调整并在保存更改前进行验证