Extract Files task

Azure Pipelines | Azure DevOps Server 2019 | TFS 2018 | TFS 2017

Use this task in a build or release pipeline to extract files from archives to a target folder using match patterns. A range of standard archive formats is supported, including .zip, .jar, .war, .ear, .tar, .7z, and more.



YAML snippet

# Extract files
# Extract a variety of archive and compression files such as .7z, .rar, .tar.gz, and .zip
- task: ExtractFiles@1
    #archiveFilePatterns: '*.zip' 
    #cleanDestinationFolder: true 


Argument Description
Archive file patterns

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

Specify match pattern filters (one on each line) that you want to apply to identify the list of archives to extract. For example:

  • test.zip extracts the test.zip file to the root folder.
  • test*.zip extracts all .zip files in the test folder.
  • *.tar extracts all .tar files in the root folder and sub-folders.
  • \bin*.7z extracts all ''.7z'' files in any sub-folder named bin.

The pattern is used to match only archive file paths, not folder paths, and not archive contents to be extracted. So you should specify patterns such as \bin\ instead of **\bin.

Destination folder Folder where the archives will be extracted. The default file path is relative to the root folder of the repo (same as if you had specified $(Build.SourcesDirectory)).
Clean destination folder before extracting Select this check box to delete all existing files in the destination folder before beginning to extract archives.
Control options

Open source

This task is open source on GitHub. Feedback and contributions are welcome.

Q & A

Where can I learn more about file matching patterns?

File matching patterns reference

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.

Do I need an agent?

You need at least one agent to run your build or release. Get an agent for Linux, macOS, or Windows.

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

See Troubleshoot Build and Release.

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

See Agent pools.

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.