Azure DevOps YAML Pipeline fails with "A sequence was not expected"

Viewed 10475

I've been attempting to create a YAML pipeline in Azure DevOps (Version Dev17.M153.3).

I created a simple Hello World C# console app and checked it into our locally hosted Azure-Git repo. I created my azure-pipelines.yml file and have tried various combinations of things in it including:

  • The ".NET Desktop" configuration
  • The "Starter Pipeline" configuration
  • A file from another C# project that I know works
  • A file form another project, with various mods to match my test project
  • A completely commented-out file
  • A completely blank file

However, every time I try to do a build, I get the following failure message:

/azure-pipelines.yml (Line: 1, Col: 1): A sequence was not expected

Given the error always occurs on line 1 and I've tried lots of different content in the file, I think something else must be configured incorrectly, rather than a problem with the YAML.

Does anyone have any ideas what I'm doing wrong, please? Various Google searches find pages with similar errors, but none of the solutions helped me.


*** Edited to add various YAML file attempts:

I currently have a completely empty YAML file, but still get the error. Previous files have included:

- 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'
1 Answers

You have here mixed few pipelines.

Here is one:


# .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

Here another but commented:

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

# .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)'

And once more:


# 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'

If you modify you pipeline on the portal you can validate using this button: enter image description here

Then you will get feedback if all is fine with your pipeline.

If you still have this issue

  • delete your pipeline from portal
  • delete your file from repo
  • start with template from portal
  • run it
  • adjust it to your need on portal and validate before saving changes
Related