Monthly Archives: September 2012

Mission: Zip with MsBuild 4.0 with no binaries in source control

I need to package results of the build to the ZIP file. Options:

  1. Zip task from MSBuild Community Tasks Project
  2. 7z.exe or something else in source control
  3. Custom task
  4. Code task

And considerations:

  1. The MSBuild Community Tasks Zip task requires tasks lib to be included before build. This actually means that you cannot download it from build script. They have Nuget Package, but if you use package restore you are out of lack.

  2. Second option is to use one of the zip compression tools. Main problem that you need this exe. So if you do not want it in your source control, you need to download it. You can try chocolatey, but I decided that this is too complicated for me.

  3. Custom task. I think this is joke.

  4. Code task. With UsingTask element you can just code your task with C# directly in MsBuild file. In most case this sounds like an overkill, but anyway I will go with this option.

Zip Task Implementation

You need something to make a zip. You can actually use any library , but I will use one that is shipped with .NET 4.5.

Important, you should have .NET 4.5 installed to make this work.

The following gist is actual implementation.

And it works Smile. Mission complete.

Tagged , ,