Utility: Copy and Publish Build Artifacts

Last Update: 3/31/2017

Team Services | TFS 2017 | TFS 2015 Update 3 | TFS 2015 RTM | Previous versions (XAML builds)

Copy build artifacts to a staging folder and then publish them to the server or a file share.

IMPORTANT

Are you using Team Services, Team Foundation Server (TFS) 2015 Update 3, or newer? If so, then we recommend that you do not use this task; it's deprecated. Instead, you should use the Copy Files and Publish Build Artifacts tasks. See Artifacts in Team Build.

You should use this task only if you're using Team Foundation Server (TFS) 2015 RTM. In that version of TFS this task is listed under the Build category and it's called Publish Build Artifacts.

Files are copied to the $(Build.ArtifactStagingDirectory) staging folder and then published.

Demands

None

Arguments

Argument Description
Copy Root

Folder that contains the files you want to copy. If you leave it empty, the copying is done from the root folder of the repo (same as if you had specified $(Build.SourcesDirectory)).

If your build produces artifacts outside of the sources directory, specify $(Agent.BuildDirectory) to copy files from the build agent working directory.

Contents

Specify pattern filters (one on each line) that you want to apply to the list of files to be copied. For example:

  • ** copies all files in the root folder.
  • **\* copies all files in the root folder and all files in all sub-folders.
  • **\bin copies files in any sub-folder named bin.
Artifact Name Specify the name of the artifact. For example: drop
Artifact Type

Choose server to store the artifact on your Team Foundation Server. This is the best and simplest option in most cases. See Artifacts in Team Build.

Control options

Q & A

Q: This step didn't produce the outcome I was expecting. How can I fix it?

This step has a couple of known issues:

  • Some minimatch patterns don't work.

  • It eliminates the most common root path for all paths matched.

You can avoid these issues by instead using the Copy Files step and the Publish Build Artifacts step.

Q: I'm having problems. How can I troubleshoot them?

A: Try this:

  1. On the variables tab, add system.debug and set it to true. Select to allow at queue time.

  2. In the explorer tab, view your completed build and click the build step to view its output.

The control options arguments described above can also be useful when you're trying to isolate a problem.

Q: How do variables work? What variables are available for me to use in the arguments?

A: $(Build.SourcesDirectory) and $(Agent.BuildDirectory) are just a few of the variables you can use. See Variables.

I use Team Foundation Server on-premises and I don't see some of these features. Why not?

Some of these features are available only on Visual Studio Team Services and not yet available on-premises. Some features are available on-premises if you have upgraded to the latest version of TFS.