Hash tool for .Net assemblies
AsemblyHasher.exe SomeLibrary.dll
AsemblyHasher.exe SomeApp.exe
# ignore AssemblVersion and AssemblyFileVersion
AsemblyHasher.exe --ignore-versions SomeLibrary.dll
# hash multiple files at once
AsemblyHasher.exe SomeLibrary.dll Another.dll A3rdone.dll
# other files (not *.dll|exe) content gets hashed too
AsemblyHasher.exe SomeLibrary.dll Picture.jpeg REAME.md
The output is a hash (using MurMur-128) of assembly contents (source code + embedded resources, which are extracted using an embedded copy of ildasm.exe).
Why not hash the .dll/.exe file directly? Because every time an assembly is compiled a few always changing values are added (MVID, timestamp, Image Base, and many others) making the file content different on every compilation. This tool will disassemble and then remove those values before hashing.
There are many possible use cases, but my main motivation for this is using it in git-based deployments to keep a cleaner history and to avoid restarting the app when no dlls have changed (IIS hot deploy).
For that purpose you can use the included powershell script GitResetUnmodifiedAssemblies.ps1
.
- .Net Framework 4.5
- Vasil Trifonov (@vtrifonov), idea and initial version published at this article
- Benjamin Eidelman (@benjamine), packing/publishing, sha1, hashing embedded resources