I keep saving a file to $(Build.ArtifactStagingDirectory)
but when checking using Get-ChildItem
, the directory is empty. Also, publishing doesn’t produce anything. Just an empty directory.
Is the only way to save files to that directory is using copy task?
2
Answers
You can use these variables only in running build or release pipelines. Each build uses own
$(Build.ArtifactStagingDirectory)
,$(Build.BinariesDirectory)
and$(Build.SourcesDirectory)
on your build agent. These folders are accessible for any cmd file or PowerShell script in the current build run.It is not the only way to use copy task to save files to other directory.
You could also use bash,cmd or PowerShell script in pipeline.
The cause of why you failed to list them:
1.You need to select folder instead of the file in Source Foler.
pipeline definition
2.This directory($(Build.ArtifactStagingDirectory)) is purged before each new build.
So the files just exist when you running the pipeline.