Created
September 17, 2013 10:30
-
-
Save blacktaxi/6592601 to your computer and use it in GitHub Desktop.
Shell script to sign a .NET assembly.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\sn.exe" -q -vf "%1" > NUL | |
if ERRORLEVEL 1 goto NOT_SIGNED | |
:SIGNED | |
echo Already signed: %~nx1 | |
goto END | |
:NOT_SIGNED | |
echo Signing %~nx1... | |
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\ildasm.exe" /out="%~dpn1.il" "%1" | |
if ERRORLEVEL 1 goto FAILED | |
if EXIST "%~dpn1.res" ( | |
"%WINDIR%\Microsoft.NET\Framework\v4.0.30319\ilasm.exe" /dll /key="%2" /resource="%~dpn1.res" "%~dpn1.il" | |
) else ( | |
"%WINDIR%\Microsoft.NET\Framework\v4.0.30319\ilasm.exe" /dll /key="%2" "%~dpn1.il" | |
) | |
if ERRORLEVEL 1 goto FAILED | |
rem Verify... | |
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\sn.exe" -q -vf "%1" > NUL | |
if ERRORLEVEL 1 goto FAILED | |
echo "Successfully signed." | |
goto END | |
:FAILED | |
echo Failed to sign %~nx1 | |
:END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment