简体   繁体   English

如何解决“YAML 文件(Azure DevOps)中的意外值和映射错误”

[英]How to resolve 'Unexpected value & mapping error in YAML file (Azure DevOps)'

For my ASP.Net Core project, I am trying to integrate CI/CD with Azure.对于我的 ASP.Net Core 项目,我正在尝试将 CI/CD 与 Azure 集成。

There, I tried to create an Azure pipeline with GitHub as follows:在那里,我尝试使用 GitHub 创建一个 Azure 管道,如下所示:
在此处输入图像描述

Since I have already created .yml file in my GitHub Repository I decided to go with the option Existing Azure Pipeline YAML file option.由于我已经在我的 GitHub 存储库中创建了.yml文件,因此我决定使用现有 Z3A580F142203677F1F0BC30898F63F5351BCDAC 选项 go选项。
在此处输入图像描述

I have already created the following yml file in the Github repo in the path .github/workflows/dotnet.yml我已经在路径.github/workflows/dotnet.yml的 Github 存储库中创建了以下yml文件

Here is the dotnet.yml file:这是 dotnet.yml 文件:

name: .NET

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Setup .NET
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: 5.0.x
    - name: Restore dependencies
      run: dotnet restore
    - name: Build
      run: dotnet build --no-restore
#     - name: Test
#       run: dotnet test --no-build --verbosity normal

But I am getting the two errors as:但我得到两个错误:

/.github/workflows/dotnet.yml(Line: 3, Col: 1): Unexpected value 'on' /.github/workflows/dotnet.yml(行:3,列:1):意外的值'on'
/.github/workflows/dotnet.yml(Line: 10, Col: 1): A mapping was not expected /.github/workflows/dotnet.yml(Line: 10, Col: 1): 不需要映射

I do not understand why I am getting these errors.我不明白为什么会收到这些错误。 When I push to the repository the .NET builds run and it builds successfully.当我推送到存储库时,.NET 构建运行并成功构建。

Can somebody please let me know how to solve these two errors and what the fault in my YAML file is?有人可以让我知道如何解决这两个错误以及我的 YAML 文件中的故障是什么吗?

It looks like you try to run github actions build this is why its not working have a look into documentation how to structure your build看起来您尝试运行 github 操作构建这就是为什么它不起作用查看文档如何构建您的构建

In Azure pipeline it will smth like this在 Azure 管道中,它会像这样

steps:
  - task: UseDotNet@2
    inputs:
      packageType: 'sdk'
      version: '5.0.x'
  - task: DotNetCoreCLI@2
    displayName: Restore
    inputs:
      command: restore
      projects: '**/*.csproj'
  - script: dotnet build --no-restore
    displayName: 'Build'
    workingDirectory: SET_WORK_DIR  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何解决 Azure devops 管道 yml 中的“意外值‘阶段’天蓝色管道” - How to resolve "unexpected value 'stages' azure pipelines" in Azure devops pipeline yml 如何解决 Yaml 语法错误“未找到预期的密钥” - Azure devops - How to resolve Yaml syntax error 'did not find expected key' - Azure devops Azure Devops Kubernetes-如何将.yaml文件上传为工件 - Azure Devops Kubernetes - how to upload .yaml file as Artifact Azure DevOps YAML 管道错误:解析块映射时未找到预期的密钥 - Azure DevOps YAML Pipeline Error: While parsing a block mapping did not find expected key 如何解决错误“找不到'Cordova / CDVPlugin.h'文件”(在Azure DevOps Xcode生成步骤期间)? - How to resolve error “'Cordova/CDVPlugin.h' file not found” (during Azure DevOps Xcode build step)? Azure devops使用Yaml文件无法构建管道 - Azure devops build pipeline with yaml file not working Azure DevOps 管道 - YAML 格式错误? - Azure DevOps Pipeline - YAML formatting error? 如何解决 Azure Devops Pipeline 中的 -apptype missing 错误 - How do I resolve the -apptype missing error in Azure Devops Pipeline 如何在 Azure DevOps YAML 的条件下使用数组 - How to use an array in a condition for Azure DevOps YAML Azure devops yaml 管道如何重置参数 - Azure devops yaml pipeline how to reset a parameter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM