MintPlayer.FolderHasher
10.2.1
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
<PackageReference Include="MintPlayer.FolderHasher" Version="10.2.1" />
<PackageVersion Include="MintPlayer.FolderHasher" Version="10.2.1" />
<PackageReference Include="MintPlayer.FolderHasher" />
paket add MintPlayer.FolderHasher --version 10.2.1
#r "nuget: MintPlayer.FolderHasher, 10.2.1"
#:package MintPlayer.FolderHasher@10.2.1
#addin nuget:?package=MintPlayer.FolderHasher&version=10.2.1
#tool nuget:?package=MintPlayer.FolderHasher&version=10.2.1
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*.logfiles in any directorynode_modules/- Matches thenode_modulesdirectory at the root level**/node_modules/- Matchesnode_modulesanywhere 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:
- File paths (sorted alphabetically, case-insensitive)
- 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 | Versions 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. |
-
net10.0
- Microsoft.Extensions.FileSystemGlobbing (>= 10.0.5)
- MintPlayer.FolderHasher.Abstractions (>= 10.0.1)
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 |