A standalone command-line tool to deduplicate assemblies (.dll and .exe files) in a .NET SDK installation by replacing duplicates with hard links or symbolic links.
- Scans an SDK directory for duplicate assemblies
- Groups duplicates by content hash (using XxHash64)
- Replaces duplicates with hard links (Windows) or symbolic links (Linux/macOS)
- Reports space savings
- Verbose mode to see detailed deduplication progress
cd /repos/sdkDedup
dotnet build -c ReleaseBuild for Windows Server 2022:
docker build -f Dockerfile.ltsc2022 -t sdkdedup:ltsc2022 .Build for Windows Server 2025:
docker build -f Dockerfile.ltsc2025 -t sdkdedup:ltsc2025 .sdkDedup <directory> [options]<directory>- Path to SDK installation directory to deduplicate
--hard-links, -h- Use hard links instead of symbolic links--verbose, -v- Enable verbose output showing each file being deduplicated
sdkDedup "C:\Program Files\dotnet" --hard-linkssdkDedup /usr/share/dotnetsdkDedup /usr/share/dotnet --verboseThe Deduplicate-And-Package.ps1 script automates the full workflow:
.\Deduplicate-And-Package.ps1 -SourceSdkPath "C:\Program Files\dotnet" -OutputPath "C:\output" -UseHardLinksThis will:
- Copy the entire dotnet installation to a temporary directory
- Run deduplication on the sdk folder within the copy
- Create a tarball of the entire dotnet installation (with deduplicated sdk)
- Clean up the temporary directory
Run the full workflow (copy + deduplicate + package):
Windows Server 2022:
docker run --rm -v C:\output:C:\output sdkdedup:ltsc2022 pwsh C:\app\Deduplicate-And-Package.ps1 -SourceSdkPath "C:\Program Files\dotnet" -OutputPath C:\output -UseHardLinksWindows Server 2025:
docker run --rm -v C:\output:C:\output sdkdedup:ltsc2025 pwsh C:\app\Deduplicate-And-Package.ps1 -SourceSdkPath "C:\Program Files\dotnet" -OutputPath C:\output -UseHardLinksOr run the deduplication tool directly:
docker run --rm -v C:\dotnet:C:\sdk sdkdedup:ltsc2022 dotnet C:\app\bin\Release\net10.0\sdkDedup.dll C:\sdk --hard-linksNote: When using Docker on Windows, you need to mount directories as volumes.
- Scan: Recursively scans the specified directory for all .dll and .exe files
- Hash: Computes a content hash (XxHash64) for each assembly
- Group: Groups files with identical content hashes
- Select Master: For each group, selects a "master" file (closest to root, alphabetically first)
- Deduplicate: Replaces all duplicates with links to the master file
- Multiple directory entries point to the same inode
- Files appear as regular files
- Requires files to be on the same filesystem
- Windows: Requires no special privileges
- Linux: Works on most filesystems
- Creates a special file that references another file
- Uses relative paths so it works when the directory is moved or archived
- Windows: May require Developer Mode or administrator privileges
- Linux: Always supported
Scanning for duplicate assemblies in '/usr/share/dotnet' (using symbolic links)...
Found 4962 assemblies eligible for deduplication.
Found 652 groups of duplicate assemblies.
Deduplication complete: 780 files replaced with symbolic links, saving 234.56 MB.
The Deduplicate-And-Package.ps1 script provides an end-to-end workflow for creating deduplicated SDK tarballs.
-SourceSdkPath(required) - Path to the source dotnet installation root-OutputPath(required) - Directory where the tarball will be created-UseHardLinks(switch) - Use hard links instead of symbolic links-VerboseOutput(switch) - Enable verbose deduplication output
- Creates a temporary working directory
- Copies the entire dotnet installation to the working directory
- Runs the deduplication tool on the sdk folder only
- Reports space savings from deduplication (parsed from tool output)
- Creates a compressed tarball of the entire dotnet installation using
tar -czf - Verifies the tarball contents
- Cleans up the temporary directory
The script creates a tarball named dotnet-deduplicated-{timestamp}.tar.gz in the specified output directory.
This tool is based on the DeduplicateAssembliesWithLinks MSBuild task from the .NET SDK build infrastructure.
Licensed to the .NET Foundation under the MIT license.