设置azure-pipelines.yml“目录'/home/vsts/work/1/a'为空."使用ASP.NET Core [英] Setup azure-pipelines.yml "Directory '/home/vsts/work/1/a' is empty." with ASP.NET Core

查看:143
本文介绍了设置azure-pipelines.yml“目录'/home/vsts/work/1/a'为空."使用ASP.NET Core的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我非常需要帮助来创建yml构建文件,因为在任何地方都找不到任何好的教程,示例或其他帮助之王.我总是收到类似的错误:看到警告,看来我的构建工件总是空的.所有步骤都成功,但是由于找不到我的文件而无法部署.愚蠢的.

I seriously need help to create my yml build file because I cannot find any good tutorial, sample or other king of help anywhere. I always get similar error: See the warning, it seems my build artifact is always empty. All step are succes but I cannot deploy because my files are not found. Stupid.

##[section]Starting: PublishBuildArtifacts
==============================================================================
Task         : Publish Build Artifacts
Description  : Publish build artifacts to Azure Pipelines/TFS or a file share
Version      : 1.142.2
Author       : Microsoft Corporation
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=708390)
==============================================================================
##[warning]Directory '/home/vsts/work/1/a' is empty. Nothing will be added to build artifact 'drop'.
##[section]Finishing: PublishBuildArtifacts

这是我的管道定义

# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- master

pool:
  vmImage: 'Ubuntu-16.04'

variables:
  buildConfiguration: 'Release'

steps:
# - script: dotnet build --configuration $(buildConfiguration)
#   displayName: 'dotnet build $(buildConfiguration)'

- task: DotNetCoreInstaller@0
  inputs:
    version: '2.2.202' # replace this value with the version that you need for your project

- script: dotnet restore

- task: DotNetCoreCLI@2
  displayName: Build
  inputs:
    command: build
    projects: '**/*.csproj'
    arguments: '--configuration Release' # Update this to match your need

- task: PublishBuildArtifacts@1
  inputs:
    ArtifactName: 'drop'

请注意我评论的第二行

# - script: dotnet build --configuration $(buildConfiguration)
#   displayName: 'dotnet build $(buildConfiguration)'

实际上是默认脚本的一部分.我没有使用默认脚本.我正在按照教程 https://docs.microsoft.com/zh-CN/azure/devops/pipelines/languages/dotnet-core?view=azure-devops

are in fact part of the default script. I'm not using the default script. I'm following the tutorial https://docs.microsoft.com/en-us/azure/devops/pipelines/languages/dotnet-core?view=azure-devops

这也是为什么我无法使用其他项目可用的模板的原因.是因为我使用的是DevOps存储库,还是因为我的项目具有特定的设置?我还有其他项目可以管理构建,然后使用图形模板和任务进行部署.容易得多.

Also why I cannot use the templates available for my other projects. Is it because I'm using DevOps repository or because my project has specific settings? I have other project I can manage the build then deployment with graphical template and task. A lot more easier.

推荐答案

是的,目前在yaml管道上的帮助似乎有些分散且稀疏.

Yes, help on yaml pipelines seem a bit scattered and thin on the ground at the moment.

由于您的项目是 AspNetCore ,我认为您缺少的是dotnet publish任务,该任务在构建之后且在PublishArtifacts之前:

Since your project is AspNetCore, I think what you're missing is the dotnet publish task, after the build and before the PublishArtifacts:

- task: DotNetCoreCLI@2
  inputs:
    command: publish
    publishWebProjects: True
    arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
    zipAfterPublish: True

但是,以下是我尝试通过Netcore Yaml管道解决沮丧问题的步骤:

But here are steps I have been through trying to resolve frustration with netcore yaml pipelines:

  1. 您已经浏览了指南的示例任务&的摘要 构建,测试和部署.NET Core应用?

  1. You have already looked through the guide's example tasks & snippets at Build, test, and deploy .NET Core apps ?

您已经注意到可以单击构建日志以查看管道中每个步骤的详细输出吗?

You have noticed that you can click on the build log to see the detailed output of each step in your pipeline?

您已经注意到任务DotNetCoreCLI@2等同于在自己的桌面上运行dotnet <command>,因此您可以在某种程度上在本地运行/调试这些任务?

You have noted that the task DotNetCoreCLI@2 is equivalent to running dotnet <command> on your own desktop so you can to some extent run/debug these tasks locally?

我发现

I found Predefined Variables gave some helpful clues. For instance it tells us that the path \agent\_work\1\a is probably the $(Build.ArtifactStagingDirectory) variable, so that helped me in mimicking the pipeline on my local machine.

从逻辑上讲,当管道到达最后一步时,您的错误消息告诉我们$(Build.ArtifactStagingDirectory)为空. dotnetcore示例页面向我建议publish是为Web项目填充它的任务.对于其他任何事情,我认为仅dotnet build任务就足够了.

Logically, your error message tells us that $(Build.ArtifactStagingDirectory) is empty when the pipeline reaches the last step. The dotnetcore example page suggests to me that publish is the task that populates it for a web project. For anything else, I think just the dotnet build task is enough.

这篇关于设置azure-pipelines.yml“目录'/home/vsts/work/1/a'为空."使用ASP.NET Core的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆