The VSTS Directory Zip and Unzip task enables you to zip multiple files and unzip zip files. The task can be installed from the Marketplace.
Zip task
In the zip task you are able to zip multiple folders to a zip files. The task creates zip archives with the name of the folder:
src/project/Modules/Common => src/project/Modules/Common.zip
In your next build step you can publish or copy the zip file to your destination location.

Unzip task
In the unzip task you are able to unzip zip files. In the ‘Zip files to unzip’ textbox you can specify multiple files to unzip. When the ‘Unzip to path’ is empty, the files will be unziped into a sub directory with the same name as the zip file.
src/project/Modules/Common.zip => src/project/Modules/Common
When you specify the ‘Unzip to path’ textbox, the zip files will be unzipped into that directory.

Add path variables
The default relative path is the folder where all sources for the build definition are synced. You can go thought other directories/files on the build agent by using full paths or variables in the path. All input boxes for paths do accept variables. For example the source directory is: $(Agent.BuildDirectory)\s. Or use your own variables for the build/release pipeline in the paths.

Path variables in VSTS
Some useful variables:
Variable | Description |
---|---|
$(System.DefaultWorkingDirectory) | Default working directory for build or release task. |
$(Build.SourcesDirectory) | Default working directory for build task. |
$(Release.ArtifactsDirectory) | Default working directory for release task. |
$(Agent.RootDirectory)\_work | The working directory for this agent. |
$(Agent.RootDirectory)\TestResults | The local path on the agent where the test results are created. |
$(Agent.BuildDirectory)\s | The folder where all sources for the build definition are synced to. |
$(Agent.BuildDirectory)\b | The local path on the agent you can use as a folder for compiled binaries. |
$(Agent.BuildDirectory)\a | The local path on the agent where any artifacts are copied to before being pushed to their destination, it will be cleaned up after the files have been copied to the destination. |
$(Agent.BuildDirectory) | The local path on the agent where all folders for a given build definition are created. |
More on variables can be found at: MSDN Use variables
Feedback
If you want to see the sources or contribute, go to GitHub. And if you like the task, please leave a review at the marketplace.
It would be nice if this extension allow exclude file when create zip file (eg. excludefile.txt or *.txt…etc)
LikeLike
The description has a small typo “Unzip zip files to a direcory”
LikeLike
Thank you for your comment. I’ll fix it in the next release.
LikeLike
Nice utility. It would be great if it was able to create sinlge zip from multiple directories.
LikeLike
Nice utility. It would be great if it was able to create single zip from multiple directories.
LikeLike
Version 1.2.0 is not working for me (d’oh!), while 1.1.4 had been working for a really long time (yay and thanks!). This happened sometime yesterday. This is from a local build agent.
##[error]File not found: ‘z:\builds\agent\_work\_tasks\Unzip_31f040e5-e040-4336-878a-59a473334434\1.2.0\ps_modules\VstsTaskSdk\VstsTaskSdk.psd1’
LikeLike
I created an update that should take care of the problem. Can you verify?
LikeLike
Booya! Works perfectly. Thanks so much and for being so quick!
LikeLike
Version 1.2.2 does not work as expected, wjile 1.1.4 was working extremly well. If we do not inform the Unzip to path (which is not mandatory) we have an error ## [error] Required: ‘destination’ input. To bypassed this probleme, we entered a path, but the files are unziped directly into this path and no more in the directory of the zip as expected (src/project/Modules/Common.zip => src/project/Modules/Common)
For info there is a wording error, it is written Upzip to path and not Unzip to path.
Any way thanks for your work
LikeLike
Version 1.2.2 broke something we use in our CD pipelines. We use the step for unzipping multiple artificacts. We then don’t specify an output folder, which causes the desired behaviour of creating a folder with the same name as the zip-file, for eacht of the referenced zips. In a single step.
Leaving this field empty now results (in the powershell script) in an error message: “##[error]Required: ‘destination’ input”
When we look at the taskdefinition, this field is specified with `required “false”`, so I can’t quite see where this message is triggered.
Entering a target folder (for example “./”) is not a solution, because then the step will extract all zip contents into that folder, without creating an intermediate folder for each referenced zipfile.
LikeLike
Ah, in the powershell script you have:
` $destination = Get-VstsInput -Name destination -Require`
While still having code to handle an empty destination inputfield, that results in the desired behaviour. Is this something you would be willing to revert?
LikeLike
I’ll fix that when I’m behind my desk. Thank you for reporting the issue.
LikeLike
@bob can you verify that the issue is fixed. I uploaded a new version of the task (1.2.3).
LikeLike
Hi, Peter, thank you!
Your fix works as expected!
LikeLike