gpt4 book ai didi

asp.net-core - 使用 ASP.NET Core 设置 azure-pipelines.yml "Directory '/home/vsts/work/1/a' 为空。”

转载 作者:行者123 更新时间:2023-12-04 02:49:18 25 4
gpt4 key购买 nike

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

##[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'

注意我评论的 2 行
# - script: dotnet build --configuration $(buildConfiguration)
# displayName: 'dotnet build $(buildConfiguration)'

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

还有为什么我不能使用其他项目可用的模板。是因为我使用的是 DevOps 存储库还是因为我的项目有特定的设置?我还有其他项目,我可以使用图形模板和任务管理构建然后部署。容易多了。

最佳答案

是的,目前对 yaml 管道的帮助似乎有点分散和单薄。
由于您的项目是 AspNetCore ,我认为您缺少的是 dotnet 发布 任务,在构建之后和 PublishArtifacts 之前:

- task: DotNetCoreCLI@2
inputs:
command: publish
publishWebProjects: True
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
zipAfterPublish: True
但以下是我尝试解决对 netcore yaml 管道的挫败感的步骤:
  • 您已经浏览了指南的示例任务和片段,位于
    Build, test, and deploy .NET Core apps ?
  • 您注意到您可以单击构建日志来查看管道中每个步骤的详细输出吗?
  • 您已经注意到任务 DotNetCoreCLI@2相当于运行 dotnet <command>在您自己的桌面上,以便您可以在某种程度上在本地运行/调试这些任务?
  • 我找到了Predefined Variables提供了一些有用的线索。例如,它告诉我们路径 \agent\_work\1\a可能是 $(Build.ArtifactStagingDirectory)变量,所以这有助于我模仿本地机器上的管道。

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

    关于asp.net-core - 使用 ASP.NET Core 设置 azure-pipelines.yml "Directory '/home/vsts/work/1/a' 为空。”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55796711/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com