0
votes

I have a publish build artifact step and then a copy step to place my UI compiled contents into the generated folder. Although the copy step succeeds and I can see in the logs that it copied my required content to the specified folder inside drop, those files are not present when I download the artifacts at the end of the build process.

Am I missing some relative path here? Are my files getting copied to a folder which is not part of the final artifacts? below are my last two tasks in yaml

- task: PublishBuildArtifacts@1
      inputs:
        PathtoPublish: '$(Build.ArtifactStagingDirectory)'
        ArtifactName: 'drop'
        publishLocation: 'Container'
    
    - task: CopyFiles@2
      inputs:
        SourceFolder: 'my-ui\dist\wwwroot\assets'
        Contents: '**'
        TargetFolder: 'drop\MyProj\wwwroot\assets'
        OverWrite: true
        CleanTargetFolder: true
1

1 Answers

3
votes

You should use the copy task to copied the required content to the specified folder in folder $(Build.ArtifactStagingDirectory) before publish build artifact task. See below:

 - task: CopyFiles@2
      inputs:
        SourceFolder: 'my-ui\dist\wwwroot\assets'
        Contents: '**'
        TargetFolder: '$(Build.ArtifactStagingDirectory)\MyProj\wwwroot\assets'
        OverWrite: true
        CleanTargetFolder: true

- task: PublishBuildArtifacts@1
      inputs:
        PathtoPublish: '$(Build.ArtifactStagingDirectory)'
        ArtifactName: 'drop'
        publishLocation: 'Container'

The Publish build artifact task will publish the contents in the $(Build.ArtifactStagingDirectory), And store the them in Azure Pipelines (Container), which is not on the local agent machine.

So if you use copy task after the Publish build artifact task. The contents is still on the local agent machine. They are not copied to the Azure Pipelines Container.