MintPlayer.FolderHasher 10.2.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package MintPlayer.FolderHasher --version 10.2.1
                    
NuGet\Install-Package MintPlayer.FolderHasher -Version 10.2.1
                    
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="MintPlayer.FolderHasher" Version="10.2.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MintPlayer.FolderHasher" Version="10.2.1" />
                    
Directory.Packages.props
<PackageReference Include="MintPlayer.FolderHasher" />
                    
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 MintPlayer.FolderHasher --version 10.2.1
                    
#r "nuget: MintPlayer.FolderHasher, 10.2.1"
                    
#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 MintPlayer.FolderHasher@10.2.1
                    
#: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=MintPlayer.FolderHasher&version=10.2.1
                    
Install as a Cake Addin
#tool nuget:?package=MintPlayer.FolderHasher&version=10.2.1
                    
Install as a Cake Tool

MintPlayer.FolderHasher

A .NET library for computing deterministic hash values of folder contents, with support for .hasherignore files (similar to .gitignore), large file streaming, and graceful error handling.

Installation

dotnet add package MintPlayer.FolderHasher

Usage

Basic Setup with Dependency Injection

using Microsoft.Extensions.DependencyInjection;
using MintPlayer.FolderHasher;
using MintPlayer.FolderHasher.Abstractions;

var services = new ServiceCollection();
services.AddFolderHasher();
var provider = services.BuildServiceProvider();

var hasher = provider.GetRequiredService<IFolderHasher>();

Computing a Folder Hash

// Simple usage - uses SHA256 by default
var hash = await hasher.GetFolderHashAsync(@"C:\MyProject");

// With folder exclusions (regex-based)
var hash = await hasher.GetFolderHashAsync(@"C:\MyProject", ["node_modules", "bin", "obj"]);

// With custom hash algorithm
using var sha512 = SHA512.Create();
var hash = await hasher.GetFolderHashAsync(@"C:\MyProject", [], sha512);

Features

.hasherignore Support

Create a .hasherignore file in any directory to exclude files from hashing. The syntax is similar to .gitignore:

# Comments start with #
*.log
*.tmp

# Directory patterns (matches at root level)
node_modules/
dist/

# Match anywhere in the tree
**/temp/

# Negation patterns
!important.log

# Specific paths
build/*.js

Pattern behavior:

  • *.log - Matches *.log files in any directory
  • node_modules/ - Matches the node_modules directory at the root level
  • **/node_modules/ - Matches node_modules anywhere in the directory tree
  • /build - Matches only at the root (leading slash)
  • !important.log - Negates previous patterns (keeps the file)

Nested .hasherignore Files

Each subdirectory can have its own .hasherignore file. Patterns in nested files apply to files within that subdirectory and its descendants.

Large File Streaming

Files larger than 10MB are automatically streamed in 80KB chunks to minimize memory usage. This allows hashing folders containing very large files without loading them entirely into memory.

Graceful Error Handling

The hasher gracefully handles:

  • Inaccessible directories - Silently skipped
  • Inaccessible files - Silently skipped
  • Permission errors - Silently skipped

This allows hashing system folders or folders with mixed permissions without throwing exceptions.

Deterministic Hashing

The hash is computed deterministically based on:

  1. File paths (sorted alphabetically, case-insensitive)
  2. File contents

The same folder contents will always produce the same hash, making it suitable for:

  • Cache invalidation
  • Change detection
  • Content verification

MSBuild Integration

For build-time folder hashing (e.g., cache invalidation in CI/CD), see MintPlayer.FolderHasher.Targets.

API Reference

IFolderHasher

public interface IFolderHasher
{
    /// <summary>
    /// Computes a SHA256 hash of the folder contents.
    /// </summary>
    Task<string> GetFolderHashAsync(string folder);

    /// <summary>
    /// Computes a SHA256 hash of the folder contents, excluding folders matching the specified patterns.
    /// </summary>
    Task<string> GetFolderHashAsync(string folder, IEnumerable<string> ignoreFolders);

    /// <summary>
    /// Computes a hash of the folder contents using the specified algorithm.
    /// </summary>
    Task<string> GetFolderHashAsync(string folder, IEnumerable<string> ignoreFolders, HashAlgorithm algorithm);
}

License

MIT

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on MintPlayer.FolderHasher:

Package Downloads
MintPlayer.FolderHasher.MSBuild

MSBuild task for computing folder hashes. Use this in csproj files to conditionally run build steps based on folder content changes.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.1 98 11/15/2026
11.0.0 102 11/15/2026
11.0.0-rc.1 93 9/17/2026
10.3.0 139 9/3/2026
10.2.1 126 8/27/2026
10.2.0 183 2/1/2026
10.1.0 146 12/28/2025
10.0.0 331 11/11/2025
10.0.0-rc.2 270 11/10/2025
10.0.0-rc.1 271 9/19/2025
9.0.0 209 11/13/2024
8.0.1 215 6/24/2024
8.0.0 210 6/24/2024