john blair
john blair

Reputation: 536

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'

Upvotes: 9

Views: 4659

Answers (4)

Reg Smith
Reg Smith

Reputation: 176

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.

Upvotes: 1

VivekDev
VivekDev

Reputation: 25389

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

Upvotes: 6

Shayki Abramczyk
Shayki Abramczyk

Reputation: 41565

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

enter image description here

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

Upvotes: 8

Rob Reagan
Rob Reagan

Reputation: 7686

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.

Upvotes: 5

Related Questions