如何将管道从视觉设计器移植到YAML管道?解析块映射时,未找到预期的密钥

时间:2018-10-29 18:05:22

标签: azure-devops yaml

由于this question,我需要切换到YAML管道。 因此,我启动了一个新的管道,并按照视觉设计器的任务将其粘贴到YAML任务中。

我猜我不需要重复这个词

steps:

因此整个流程现在已经

pool:
  vmImage: 'VS2017-Win2016'

variables:
  buildConfiguration: 'Debug'

steps:
- task: DotNetCoreInstaller@0
  displayName: 'Use .NET Core sdk 2.1.5'
  inputs:
    version: 2.1.403


- task: DotNetCoreCLI@2
  displayName: Restore
  inputs:
    command: restore

    projects: '**/Api*.csproj'

    #Your build pipeline references an undefined variable named ‘Parameters.projects’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references the ‘BuildConfiguration’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971

- task: DotNetCoreCLI@2
  displayName: Publish
  inputs:
    command: publish

    publishWebProjects: false

    projects: '$(Parameters.projects)'

    arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)'

    - task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'

但这会导致错误

azure-pipelines.yml (Line: 35, Col: 5, Idx: 1118) - (Line: 35, Col: 6, Idx: 1119): While parsing a block mapping, did not find expected key.

1 个答案:

答案 0 :(得分:2)

问题出在此行- task: PublishBuildArtifacts@1(带空格的行)中。只需将文本粘贴到行首即可。

pool:
  vmImage: 'VS2017-Win2016'

variables:
  buildConfiguration: 'Debug'

steps:
- task: DotNetCoreInstaller@0
  displayName: 'Use .NET Core sdk 2.1.5'
  inputs:
    version: 2.1.403


- task: DotNetCoreCLI@2
  displayName: Restore
  inputs:
    command: restore

    projects: '**/Api*.csproj'

    #Your build pipeline references an undefined variable named ‘Parameters.projects’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references the ‘BuildConfiguration’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971

- task: DotNetCoreCLI@2
  displayName: Publish
  inputs:
    command: publish

    publishWebProjects: false

    projects: '$(Parameters.projects)'

    arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)'

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'