如何在 azure yaml 管道中以 zip 形式发布和下载工件

问题描述 投票:0回答:1

我将经典管道转换为 onebranch yaml 管道。所有任务均已完成,但无法查看工件文件夹内的 zip 文件。我已经添加了用于构建和发布网络的 yaml 代码,如下所示,

              - task: UseDotNet@2
                 displayName: 'Use .NET Core sdk 6.x'
                 inputs:
                   version: 6.x    
               - task: DotNetCoreCLI@2
                 displayName: Build Web solution
                 inputs:
                   command: build
                   projects: >-
                     {solutionpath}
                
               - task: DotNetCoreCLI@2
                 displayName: Publish Web Solution
                 inputs:
                   command: publish
                   publishWebProjects: false
                   projects: >-
                      {solutionpath}

                   arguments: >-
                      --configuration Release --output
                      '$(REPOROOT)\obartifacts'
                   zipAfterPublish: true
                   modifyOutputPath: false

但我无法将工件视为 zip 文件夹。如果我缺少任何内容,请告诉我。但我收到如下错误,

The imported project "C:\__t\dotnet\sdk\6.0.427\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "C:\__t\dotnet\sdk\6.0.427\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication.targets" is correct, and that the file exists on disk.

               
azure-devops yaml azure-pipelines
1个回答
0
投票

您没有添加 PublishPipelineArtifact@1 任务来从输出目录发布生成的 ZIP 文件。

您可以如下设置管道:

#azure-pipelines.yml

variables:
  buildConfiguration: 'Release'

jobs:
- job: build
  displayName: 'Build'
  steps:
  - task: DotNetCoreCLI@2
    displayName: 'Build Web solution'
    inputs:
      command: 'build'
      projects: 'path/to/solution.sln'
      arguments: '-c $(buildConfiguration)'
  
  # Output the generate ZIP file into the directory "$(Build.ArtifactStagingDirectory)/obartifacts".
  - task: DotNetCoreCLI@2
    displayName: 'Publish Web solution'
    inputs:
      command: 'publish'
      publishWebProjects: false
      projects: 'path/to/solution.sln'
      arguments: '--no-build -c $(buildConfiguration) -o $(Build.ArtifactStagingDirectory)/obartifacts'
      modifyOutputPath: false

  # Publish the ZIP file from the directory "$(Build.ArtifactStagingDirectory)".
  - task: PublishPipelineArtifact@1
    displayName: 'Publish Pipeline Artifact'
    inputs:
      targetPath: '$(Build.ArtifactStagingDirectory)'
      artifact: drop

结果。

enter image description here

然后在后续作业或管道中,您可以使用 DownloadPipelineArtifact@2 任务从构建作业下载已发布的 ZIP 文件。


© www.soinside.com 2019 - 2024. All rights reserved.