简体   繁体   中英

On Azure Dev Ops: How do I view the content of the package location directory $(Build.ArtifactStagingDirectory)

I have done a successful build pipeline of my asp.net website which has packaged my website to $(Build.ArtifactStagingDirectory) as a zip file. How do I view the content of this directory via dev.azure.com?

I expected to be able to view it in the Artifacts view but that only show package feeds with no options to view zip files.

Tried to look at Artifacts and copy file to a drop folder - neither of them visible anywhere.

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'


- task: CopyFiles@2
  inputs:
    SourceFolder: '$(Build.ArtifactStagingDirectory)'
    Contents: '**'
    TargetFolder: 'drop'

Yeah, finding where files exist when constructing your Pipeline is a bit like trying to build a ship in a bottle. Use the command line task to run a script where you execute a dir command to see a directory's contents. Then you can see the actual files (and paths) echoed in the logs. Something along the lines of

- task: CmdLine@2
  displayName: 'Directory listing - Build.ArtifactStagingDirectory'
  inputs:
    script: |
      D:
      cd $(Build.ArtifactStagingDirectory)
      dir /b /s

I actually can't remember if that directory is on C: or D: so you may have to experiment.

You should add Publish Build Artifacts task at the end of the build, then the zip file will be available in the build summary, and you could download it in the release:

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'

在此处输入图像描述

When will you click on the Artifacts you will see the file.

If you using a linux agent( ubuntu-latest for example) the following can help.

    - task: CmdLine@2
      displayName: 'Directory listing - Build.ArtifactStagingDirectory'
      inputs:
        script: |
          cd $(Build.ArtifactStagingDirectory)
          ls -Rla

The output can look something like this.

total 12
drwxr-xr-x 3 vsts docker 4096 Oct  5 09:08 .
drwxr-xr-x 6 vsts docker 4096 Oct  5 09:08 ..
drwxr-xr-x 5 vsts docker 4096 Oct  5 09:08 reactonacraks

./reactonacraks:
total 540
drwxr-xr-x 5 vsts docker   4096 Oct  5 09:08 .
drwxr-xr-x 3 vsts docker   4096 Oct  5 09:08 ..
-rw-r--r-- 1 vsts docker    310 Oct  5 09:08 .gitignore
-rw-r--r-- 1 vsts docker    195 Oct  5 09:08 Dockerfile
-rw-r--r-- 1 vsts docker    223 Oct  5 09:08 Dockerfile.dev
-rw-r--r-- 1 vsts docker   3362 Oct  5 09:08 README.md
drwxr-xr-x 3 vsts docker   4096 Oct  5 09:08 iac
-rw-r--r-- 1 vsts docker    817 Oct  5 09:08 package.json
drwxr-xr-x 2 vsts docker   4096 Oct  5 09:08 public
drwxr-xr-x 2 vsts docker   4096 Oct  5 09:08 src
-rw-r--r-- 1 vsts docker 510352 Oct  5 09:08 yarn.lock

I have a dumb little workaround I just used.

I added a command line task to my build pipeline. 在此处输入图像描述

I then expanded the advanced options and clicked on the ellipses beside the option to view my working directory. 在此处输入图像描述

I think this does what you're asking for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM