What is the difference between Copy Files vs Publish Artifact task in VSTS?

tRuEsatm picture tRuEsatm · Sep 25, 2017 · Viewed 11.1k times · Source

In my Copy Files task, I am copying the required files to the file share location from which I will be doing the deployment. What is the use of publishing artifact step? Or it is obsolete in my case. I am confused about the what values should be put in the boxes.

enter image description here

Answer

Marina Liu picture Marina Liu · Sep 26, 2017
  • If you need to copy files/artifacts to VSTS server, Publish Artifacts task is the only option (by selecting Server for Artifact Type option).
  • If you need to copy files/artifacts to a share path, both Publish Artifacts task and Copy Files task are ok. And Copy Files task is a little more flexible than Publish Artifacts task since you can specify which files to be copied to share path in Contents option.

And for your situation, you can use any of the tasks (Publish Artifacts task and Copy Files task). Since you only need to copy the contents under $(build.artifactstagingdirectory) to the share path \\my\share\$(Build.DefinitionName)\$(Build.BuildNumber), both the tasks can also achieve it.

  • If you use the Publish Artifacts task, settings as you specified in the picture is ok. It will copy the contents under $(build.artifactstagingdirectory) to \\my\share\$(Build.DefinitionName)\$(Build.BuildNumber)\drop.

  • If you use the Copy Files task, settings as be set as below. It will also the same result as the Publish Artifacts task.

    enter image description here