Azure Pipeline完成后看不到我的构建工件

时间:2019-10-15 09:45:01

标签: azure azure-devops yaml azure-pipelines azure-pipelines-build-task

我有一个非常简单的管道Yaml(请参见下文)

我想要的是在解决方案中构建项目,并保留创建的工件,以便我可以在单独的发布管道中将其发布到Azure。

我记得以前做过类似的事情,当它起作用时,我可以在成功的构建列表项旁边看到一个查看构建工件的选项。但是,我再也没有这种东西了。

我在这里想念什么?

管道:

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: DotNetCoreCLI@2
  inputs:
    command: 'restore'
    projects: '**/*.csproj'
- task: DotNetCoreCLI@2
  inputs:
    command: 'build'
    projects: '**/*.csproj'
    zipAfterPublish: true

4 个答案:

答案 0 :(得分:2)

您可以添加类似的内容(复制到工件文件夹并发布):

- task: CopyFiles@2
       displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
       inputs:
       SourceFolder: '$(system.defaultworkingdirectory)'
       Contents: '**\bin\$(BuildConfiguration)\**'
       TargetFolder: '$(build.artifactstagingdirectory)'
       condition: succeededOrFailed()

- task: PublishBuildArtifacts@1
       displayName: 'Publish Artifact: drop'
       inputs:
       PathtoPublish: '$(build.artifactstagingdirectory)'
       condition: succeededOrFailed()

答案 1 :(得分:1)

我根据ms文档提供了答案(所有详细信息都可以在https://docs.microsoft.com/en-us/azure/devops/pipelines/ecosystems/dotnet-core?view=azure-devops中找到)。

基于DotNetCoreCLI的三个任务(还原,构建和发布以纠正dir)以及将工件发布到提要的最后一个任务。

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:

- task: DotNetCoreCLI@2
  displayName: Restore
  inputs:
    command: restore
    projects: '**/*.csproj'

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

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

# this code takes all the files in $(Build.ArtifactStagingDirectory) and uploads them as an artifact of your build.

- task: PublishBuildArtifacts@1
  displayName: "Publish as artifact"
  inputs:
    pathtoPublish: '$(Build.ArtifactStagingDirectory)' 
    artifactName: 'myWebsiteName'

答案 2 :(得分:0)

您必须发布Build Artifact,使用此任务:

Publish Artifact

之后,您可以在“摘要”下检查工件:

Artifact

答案 3 :(得分:0)

尝试添加CopyFiles任务和PublishBuildArtifacts任务:

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: DotNetCoreCLI@2
  inputs:
    command: 'restore'
    projects: '**/*.csproj'
    feedsToUse: 'config'
- task: DotNetCoreCLI@2
  inputs:
    command: 'build'
    projects: '**/*.csproj'
    zipAfterPublish: true

- task: CopyFiles@2
  displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
  inputs:
    SourceFolder: '$(agent.builddirectory)'
    TargetFolder: '$(Build.ArtifactStagingDirectory)'

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'

enter image description here