LittlePack 2.0.0

dotnet add package LittlePack --version 2.0.0
                    
NuGet\Install-Package LittlePack -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LittlePack" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LittlePack" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="LittlePack" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LittlePack --version 2.0.0
                    
#r "nuget: LittlePack, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LittlePack@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LittlePack&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=LittlePack&version=2.0.0
                    
Install as a Cake Tool

LittlePack

Version: 2.0.0_Beta This is the second major release of LittlePack, upgraded from .NET 4.0 to .NET 8.0 and rebuilt with full CLI support, encryption, pattern filtering, and test coverage.

LittlePack is a lightweight C# library for packing and unpacking collections of files into a single compressed byte array. It supports GZip compression, relative file path preservation, optional AES encryption, and filtering via wildcards. This library is ideal for bundling files for transport, backup, or use in custom archival formats.


✨ Features

  • Pack and unpack collections of files using a simple Record model
  • Preserves folder structure using relative paths
  • Uses GZip for compression
  • Optional AES encryption using a password
  • Supports file filtering via --ignore, --only, and .littlepackignore patterns
  • Designed for integration into CLI or backend tools

🧰 Usage

Packing Files (from Folder)

var files = Directory.GetFiles("./input", "*", SearchOption.AllDirectories);
var records = files.Select(f => new Record(
    Path.GetRelativePath("./input", f),
    File.ReadAllBytes(f))
).ToList();

var packer = new Packer(records);
var packedBytes = packer.Pack();
File.WriteAllBytes("archive.lpkg", packedBytes);

Manual Packing (Individual Files)

var packer = new Packer();

packer.Records.Add(new Record { FileName = "file1.png", Data = File.ReadAllBytes(@"C:\\Data\\file1.png") });
packer.Records.Add(new Record { FileName = "file2.png", Data = File.ReadAllBytes(@"C:\\Data\\file2.png") });
packer.Records.Add(new Record { FileName = "file3.png", Data = File.ReadAllBytes(@"C:\\Data\\file3.png") });

byte[] package = packer.Pack();
File.WriteAllBytes(@"C:\\Temp\\package.pack", package);

Unpacking Files

var packedBytes = File.ReadAllBytes("archive.lpkg");
var records = Packer.Unpack(packedBytes);
records.SaveTo("./output");

Optional Encryption

// Encrypt
var encrypted = CryptoUtility.Encrypt(packedBytes, "MyPassword");
File.WriteAllBytes("secure.lpkg", encrypted);

// Decrypt
var decrypted = CryptoUtility.Decrypt(File.ReadAllBytes("secure.lpkg"), "MyPassword");
var records = Packer.Unpack(decrypted);

🧪 Testing

Unit tests are included for:

  • Encryption and decryption round-trips
  • Packing/unpacking byte-level consistency
  • CLI argument parsing and pattern filtering

To run tests:

dotnet test

📁 Project Structure

  • Record.cs - Represents a file (name + data)
  • Packer.cs - Handles pack/unpack logic with compression
  • CryptoUtility.cs - AES encryption and decryption helpers
  • LittlePackExtensions.cs - File saving helpers
  • CliParser.cs - CLI argument parsing and .littlepackignore support
  • LittlePackCli.cs - Main runner for CLI mode

📄 License

MIT License. Use it, fork it, break it, fix it — enjoy.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 156 6/19/2025
1.0.0.1 1,637 5/18/2015 1.0.0.1 is deprecated because it is no longer maintained.