Last active
March 15, 2020 23:35
-
-
Save 3F/b7b7c8165948645edb7a868f9b9a6831 to your computer and use it in GitHub Desktop.
PublicKey from .dll or .snk or .pfx
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 | |
:: PublicKey <.dll or .snk or .pfx> | |
set file=%1 & set ext=%~x1 | |
if not exist %file% goto notfound | |
if "%ext%"==".dll" ( | |
call sn -q -Tp %file% || goto err | |
goto exit | |
) | |
if not "%ext%"==".snk" if not "%ext%"==".pfx" goto invalid | |
set pubkey="%~1_pubkey_%random%%random%%ext%" | |
call sn -q -p %file% %pubkey% || goto err | |
call sn -tp %pubkey% || goto err | |
goto exit | |
:cleanup | |
if defined pubkey if exist %pubkey% ( | |
del %pubkey% /Q/F | |
) | |
exit /B 0 | |
:notfound | |
echo File '%file%' was not found. 1>&2 | |
exit /B 2 | |
:invalid | |
echo Unsupported file type '%ext%'. Try with .dll; .snk; .pfx 1>&2 | |
exit /B 1 | |
:err | |
call :cleanup | |
echo Something went wrong 1>&2 | |
exit /B 1 | |
:exit | |
call :cleanup | |
exit /B 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment