Utility: Archive Files

Last Update: 12/12/2016

Team Services | TFS 2017 | Previous versions (XAML builds)

Create an archive file from a source folder. A variety of standard archive formats are supported including: .zip, .jar, .war, .ear, .tar, .7z., and others.

Demands

None

Arguments

Argument Description
Root folder (or file) to archive

The folder (or file) you wish to archive. The default file path is relative from the root folder of the repo (same as if you had specified $(Build.SourcesDirectory)).

If the specified path is a folder, recursively, all nested files and folders will be included in the archive.

If the specified path is a file, only the single file will be included in the archive.

Prefix root folder name to archive paths If selected, the root folder name will be prefixed to file paths within the archive. Otherwise, all file paths will start one level lower.

For example, suppose the selected root folder is: /home/user/output/classes/, and contains: com/acme/Main.class.

  • If selected, the resulting archive would contain: classes/com/acme/Main.class.
  • Otherwise, the resulting archive would contain: com/acme/Main.class..
Archive type Specify the compression scheme used. To create foo.jar, for example, choose zip for the compression, and specify foo.jar as the archive file to create. For all tar files (including compressed ones), choose tar.

  • zip - default, zip format, choose this for all zip compatible types, (.zip, .jar, .war, .ear)
  • 7z - 7-Zip format, (.7z)
  • tar - tar format, choose this for compressed tars, (.tar.gz, .tar.bz2, .tar.xz)
  • wim - wim format, (.wim)
Tar compression Only applicable if the tar archive type is selected.

Optionally choose a compression scheme, or choose None to create an uncompressed tar file.

  • gz - default, gzip compression (.tar.gz, .tar.tgz, .taz)
  • bz2 - bzip2 compression (.tar.bz2, .tz2, .tbz2)
  • xz - xz compression (.tar.xz, .txz)
  • None - no compression, choose this to create a uncompressed tar file (.tar)
Archive file to create Specify the name of the archive file to create. The file extension should match the selected archive type. For example to create foo.tgz, select the tar archive type, gz for tar compression.
Replace existing archive If an existing archive exists, specify whether to overwrite it. Otherwise, files will be added to it as long as it is not a comprssed tar.

If adding to an existing archive, these types are supported:

  • zip
  • 7z
  • tar - uncompressed only
  • wim
Control options

Q & A

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.

Do I need a build agent?

You need at least one agent to run your build. Get an agent.

I can't select a default agent queue and I can't queue my build. How do I fix this?

See queues.

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.