Copy and Publish Build Artifacts task

TFS 2015

Use this task in a build or release pipeline to copy build artifacts to a staging folder and then publish them to the server or a file share. Files are copied to the $(Build.ArtifactStagingDirectory) staging folder and then published.

Important

If you're using Azure Pipelines, or Team Foundation Server (TFS) 2017 or newer, we recommend that you do NOT use this deprecated task. Instead, use the Copy Files and Publish Build Artifacts tasks. See Artifacts in Azure Pipelines.

Important

Are you using Team Foundation Server (TFS) 2015.4? If so, we recommend that you do NOT use this deprecated task. Instead, use the Copy Files and Publish Build Artifacts tasks. See Artifacts in Azure Pipelines.

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 is named Publish Build Artifacts.

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 Azure Pipelines.

Control options

Q & A

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

This task 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 task and the Publish Build Artifacts task.

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. Variables are available in expressions as well as scripts; see variables to learn more about how to use them. There are some predefined build and release variables you can also rely on.

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

Some of these features are available only on Azure Pipelines and not yet available on-premises. Some features are available on-premises if you have upgraded to the latest version of TFS.