Search code examples
.net.net-4.6cakebuild

Cake Script - Unable to refer .Net 4.6 library


Here is the my cake script.

#reference "System.IO.Compression.dll";
#reference "System.IO.Compression.FileSystem.dll";
using System;

var target = Argument("target", "Default");

Task("UnzipDoc")
    .Does(() =>
{   
    System.IO.Compression.ZipArchive archive = System.IO.Compression.ZipFile.OpenRead("test.zip");  
});

Task("Default")
    .IsDependentOn("UnzipDoc");

RunTarget(target);

Executing this script using build.ps1 gives error that ZipArchive does not exist.

I am using Cake v0.26.1 on Windows 7 64bit machine with VS2015 installed.


Solution

  • To reference assemblies in the GAC omit the file extension (.dll) so it just reads "System.IO.Compression", that said there's built in aliases for unzipping too.

    Unzip("Cake.zip", "./cake");
    

    Read more at ZipAliases Unzip