Created
October 8, 2014 11:17
-
-
Save sharwell/00100f5e54d971058d72 to your computer and use it in GitHub Desktop.
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
param( | |
[string]$Assembly, | |
[string]$ExpectedKey, | |
[string]$Build = $null | |
) | |
function Get-PublicKeyToken() { | |
param([string]$assembly = $null) | |
if ($assembly) { | |
$bytes = $null | |
$bytes = [System.Reflection.Assembly]::ReflectionOnlyLoadFrom($assembly).GetName().GetPublicKeyToken() | |
if ($bytes) { | |
$key = "" | |
for ($i=0; $i -lt $bytes.Length; $i++) { | |
$key += "{0:x2}" -f $bytes[$i] | |
} | |
$key | |
} | |
} | |
} | |
if (-not $Build) { | |
$Build = $Assembly | |
} | |
$actual = Get-PublicKeyToken -assembly $Assembly | |
if ($actual -ne $ExpectedKey) { | |
$host.ui.WriteErrorLine("Invalid publicKeyToken for '$Build'; expected '$ExpectedKey' but found '$actual'") | |
exit 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment