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.

- 3,517
- 6
- 43
- 83
2 Answers
- 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.

- 36,876
- 5
- 61
- 74
-
By VSTS server you mean a hosted agent in the cloud or on-prem? I have set up an agent on-prem. – tRuEsAtM Sep 26 '17 at 16:43
-
No, it's not build agent related. Server for artifacts type means the artifacts are uploaded to VSTS itself, and you can download the artifacts through the build summary page. The conditions listed in the answer all suitable for hosted agent and op-prem agent. – Marina Liu Sep 27 '17 at 01:08
-
I was wondering if, when a build is deleted, the Publish Artifact task would cleanup the drop to a shared folder. We have been using the Copy Files task for some time and I noticed that there are lots of folders in the drop location for build that do not even exist anymore... – Sup3rHugh Jul 20 '18 at 15:59
-
can you define content to to be published also with publish task or only folder which copies everything in the folder? – Emil Sep 23 '19 at 16:22
-
I am building a console application and want to deploy it to onprem server but I am unable to copy the build exe to the shared path. I have onprem deployment agent running which hosted an MVC website in IIS using CICD pipeline on AzureDevOps. But when I am dealing with console app it is not copying the final EXE to onprem agent shared path. I tried both ways in build pipeline which you may see here: https://dev.azure.com/MSTCsandippatel/DemoConsoleApp/_build?definitionId=5&_a=summary Can I deploy console/win app like website to onprem machine or am I doing it wrong-should I try CD task? – sapatelbaps Nov 05 '19 at 04:02
I have found out another difference which is when builds are cleaned up (deleted either manually or when retention rule deletes them).
When using Publish Artifacts task with a shared folder as destination, cleanup of the drop folder is done. When using Copy Files task, cleanup of the drop folder is not done.
If cleanup of shared folder is an issue for you, switching to using the Publish Artifacts task seems like a good idea.
Hope this helps.

- 677
- 7
- 15