Search code examples
node.jsazureazure-devopsartifact

Azure Devops - Clean Destination Directory Before Deployment


I have a Azure Devops build step like so:

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

The publish step just deploys the app on top of what is currently in the directory, but in the meantime the entire app structure may have changed. Is there any way to clear the destination directory before the publish step takes place?


Solution

  • You could add a DeleteFiles task before PublishBuildArtifact, to clear the destination directory.