Skip to main content

Archive Compression

In many situations you have to deal with compressed archives. Good examples are when you want to provide additional assets for your GitHub releases, or when you depend on other project's release assets yourself, and need to extract them before they can be used.

note

Please refer to the SharpZipLib documentation for any questions.

Compressing Archives​

You can create a compressed archive from a directory follows:

Build.cs
// using static Nuke.Common.IO.CompressionTasks;

CompressZip(
PublishDirectory,
ArchiveFile,
filter: x => !x.Extension.EqualsAnyOrdinalIgnoreCase(ExcludedExtensions),
compressionLevel: CompressionLevel.SmallestSize,
fileMode: FileMode.CreateNew);
tip

If you want to allow your consumers to verify the integrity of your archive files, you can calculate their MD5 checksums and publish them publicly:

// using static Nuke.Common.IO.FileSystemTasks;

var checksum = GetFileHash(ArchiveFile);

Extracting Archives​

You can extract an existing archive file to a directory:

Build.cs
// using static Nuke.Common.IO.CompressionTasks;

UncompressZip(ArchiveFile, PublishDirectory);