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
PublishDirectory.ZipTo(
ArchiveFile,
filter: x => !x.HasExtension(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:

var checksum = ArchiveFile.GetFileHash();

Extracting Archives

You can extract an existing archive file to a directory:

Build.cs
ArchiveFile.UnZipTo(PublishDirectory);