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


Solution 1:[1]

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.

Solution 2:[2]

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

Solution 3:[3]

I have a dumb little workaround I just used.

I added a command line task to my build pipeline. enter image description here

I then expanded the advanced options and clicked on the ellipses beside the option to view my working directory. enter image description here

I think this does what you're asking for.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rob Reagan
Solution 2 VivekDev
Solution 3 Reg Smith