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.

Advertisements
Tagged , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s