Resolved- Azure Directory is empty. Nothing will be added to build artifact ‘drop’

Issue Description

Azure ADO build commands give below error,

##[warning]Directory ‘/home/vsts/work/1/a’ is empty. Nothing will be added to build artifact ‘drop’.

Directory'/home/vsts/work/1/a' is empty. Nothing will be added to build artifact'drop'.

Resolution

The error I found to be due to missing artifacts after the build process. Please copy and add artifacts from the build location.

The missing artifacts were visible in the pipeline as it shows ‘0’ artifacts.

Directory'/home/vsts/work/1/a' is empty

I was able to fix the issue using a predefined task for publishing – PublishBuildArtifacts@1 and for CopyFiles@2.

Below sample YAML with changes are highlighted.

trigger:
- master

pool:
  vmImage: ubuntu-latest

variables:
  buildConfiguration: 'Release'

steps:
- script: dotnet build --configuration $(buildConfiguration)
  displayName: 'dotnet build $(buildConfiguration)'


- task: CopyFiles@2
  inputs:
    targetFolder: '$(Build.ArtifactStagingDirectory)'    

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


In the above command,

  • pathToPublish: This is path your artifact. and could be absolute or a relative path.
  • artifactName: Name of your artifact.

After modification as above and triggering the build, I was able to publish the artifacts package.

Nothing will be added to build artifact'drop'

References :

That’s all! Happy coding!

Does this help you fix your issue?

Do you have any better solutions or suggestions? Please sound off your comments below.



Please bookmark this page and share it with your friends. Please Subscribe to the blog to receive notifications on freshly published(2024) best practices and guidelines for software design and development.



Leave a Reply

Your email address will not be published. Required fields are marked *