Skip to content

Getting started with the Zip activity

rfennell edited this page Aug 3, 2014 · 2 revisions

The zip activity can be used to create, update or extract zip archive files. In this example we aim to show the the basic steps that are required to get the activity integrated into a build.

Before you can make use of any of the TFS community build activities you have to make sure they are available for the build system and on your development PC. Instructions for this process can be found in the ALM Rangers build guide or in the getting started page of this wiki. This page assumes the Zip activity is available in the developers build process workflow toolbox. Hence we are able to build the workflow shown below

Configuring the activity

Using the zip activity is very straight forward, once it is dropped onto the build process design surface only three properties (as a minimum) have to be set for each of the available actions

  • AddFiles – Requires: ZipFileName, CompressPath or Files
  • Create – Requires: ZipFileName, CompressPath or Files
  • Extract – Requires: ZipFileName, ExtractPath

In this example we build a project containing a default ClassLibrary project. The Zip activities have been added at the end of the build process (as the last action in the agents sequence) as follows

  1. zip up the log folder from the build drops location
  2. unzip it to a folder
  3. add a DLL file to the zip
  4. unzip it to a second folder

Screenshot

The configuration of each instance of the activity is as follows

Screenshot Screenshot Screenshot Screenshot

It can be seen that in all cases we set the Action and the ZipFileName, then depending upon the action, we then either set the source folder (CompressPath) or a file list (Files), or the extract location (ExtractPath). The properties can all make use of build variables or arguments as required. In this sample we are just using the DropLocation variable and fixed filenames

Property Description
Action Set to the required action for the activity, based on a fixed list of Create, AddFiles or Extract
CompressionLevel Set to the BestCompression, BestSpeed, Default, Level0 to Level9 or None
CompressionPath A folder to act as the source for a Create or AddFiles actions
DisplayName The name of the activity in the log, good idea to make it meaningful
ExtractPath The folder used as a target for the Extract action
FailBuildOnError If an error flag the build as failed
Files An array of filename to add to the zip file. Note this cannot contain wildcards. if you wish to use a wildcard you need to use a FileMatchingFile activity as used with the StyleCop activity
IgnoreExceptions If true the activity will complete swallow any exceptions
LogExceptionStack If true logs any exceptions information
Password Set the password to use for the zip file
RemoveRoot A string that defines a path that will be trimmed from the front of file paths when the file is added to the zip. It is used, as it is in the AddFiles sample above, so that the file would be added to the zip in the root and not in in a folder structure based on the drop location path
TreatWarningsAsErrors If true any warnings will be handles as build errors
ZipFileName The name, including path, for the ZIP file, this property always has to be set.

Running the activity

When you run this workflow you should see a zip file created on the drop location and a pair of unzip folders

Screenshot

Screenshot

Clone this wiki locally