3
votes

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
Please share your YAML with usKrzysztof Madej
Sounds like your YAML file starts with a dash symbol (-), which should not be the case. See schema reference for more info: docs.microsoft.com/en-us/azure/devops/pipelines/…Yan Sklyarenko
Welcome to StackOverflow! Please ensure that your question is specific and provides the right level of detail. In this example, you’ve provided some troubleshooting history but not the specifics. “A sequence was not expected” is a YAML error, please provide the YAML and other relevant details such as hosted or self-hosted build agent.bryanbcook
Thanks for the feedback. Original post now edited to include YAML attempts.Martin Walker
Hi @MartinWalker, Is there any update for this issue? Feel free to let me know if the answer could give you some help. Just a reminder of this.Vito Liu

1 Answers

1
votes

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