[英]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.