I just want more info than what AssemblyName gives.
Writes AssemblyName values, values of all Assembly attributes starting with Assembly (i.e. /^Assembly.*/
), and also prints the strong name key, if any.
Requires Visual Studio 2019 Community edition to be installed for the Strong Name Utility. If you have a different Visual Studio installation, change the "Import-Module" @ line 56 in the code to match it.
Add the content of the Get-AssemblyInfo.ps1
script below into your powershell profile.
Short script doing just that:
$profileText = Get-Content $PROFILE -ErrorAction SilentlyContinue -Raw;
if ($null -ne $profileText -and $profileText.Contains("https://gist.github.com/jilleJr/66c3bdddf2c60c0dcb5f9cb21cb6a19f")) {
Write-Host "Already installed to $PROFILE" -ForegroundColor DarkYellow
} else {
$content = (Invoke-WebRequest -UseBasicParsing 'https://gist.github.com/jilleJr/66c3bdddf2c60c0dcb5f9cb21cb6a19f/raw/e304d031fb253814e943fb3f249ce07c5bc1987b/Get-AssemblyInfo.ps1').Content;
[IO.File]::WriteAllLines($PROFILE, "$profileText`n$content");
Write-Host "Installed to $PROFILE" -ForegroundColor Green;
}
AssemblyName values
Name : Moq
Version : 4.8.0.0
CultureInfo :
CultureName :
CodeBase : file:///C:/Users/kalle/.nuget/packages/moq/4.8.1/lib/net45/Moq.dll
EscapedCodeBase : file:///C:/Users/kalle/.nuget/packages/moq/4.8.1/lib/net45/Moq.dll
ProcessorArchitecture : MSIL
ContentType : Default
Flags : PublicKey
HashAlgorithm : SHA1
VersionCompatibility : SameMachine
KeyPair :
FullName : Moq, Version=4.8.0.0, Culture=neutral, PublicKeyToken=69f491c39445e920
Assembly attributes values
Name Value
---- -----
Company "Clarius Consulting, Manas Technology Solutions, InSTEDD"
Configuration "RELEASE"
FileVersion <null>
InformationalVersion "4.8.1-tags/v4.8.1+de5c25c"
Product "Moq"
Title "Moq"
Trademark ""
Assembly references
Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc
mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Threading.Tasks.Extensions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
Assembly Strong Name Utility values
**********************************************************************
** Visual Studio 2019 Developer PowerShell v16.4.2
** Copyright (c) 2019 Microsoft Corporation
**********************************************************************
#Public key token:
Microsoft (R) .NET Framework Strong Name Utility Version 4.0.30319.0
Copyright (c) Microsoft Corporation. All rights reserved.
Public key (hash algorithm: sha1):
00240000048000009400000006020000002400005253413100040000010001009f7a95086500f8
f66d892174803850fed9c22225c2ccfff21f39c8af8abfa5415b1664efd0d8e0a6f7f2513b1c11
659bd84723dc7900c3d481b833a73a2bcf1ed94c16c4be64d54352c86956c89930444e9ac15124
d3693e3f029818e8410f167399d6b995324b635e95353ba97bfab856abbaeb9b40c9b160070c63
25e22ddc
Public key token is 69f491c39445e920
#Verified?
Microsoft (R) .NET Framework Strong Name Utility Version 4.0.30319.0
Copyright (c) Microsoft Corporation. All rights reserved.
Assembly 'C:\Users\kalle\.nuget\packages\moq\4.8.1\lib\net45\Moq.dll' is valid
This tool can only operate if the assembly strong name is valid or if strong name verification is disabled.
If you are working with unverifiable assemblies (such as delayed signed) you will have to disable strong name verification for that assembly.
Caution: Use this option only during development. Adding an assembly to the skip verification list creates a security vulnerability. A malicious assembly could use the fully specified assembly name (assembly name, version, culture, and public key token) of the assembly added to the skip verification list to fake its identity. This would allow the malicious assembly to also skip verification.
https://docs.microsoft.com/en-us/dotnet/framework/tools/sn-exe-strong-name-tool
Run as administrator. Example shows how to disable verification for Newtonsoft.Json
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\StrongName\Verification\Newtonsoft.Json,30ad4fe6b2a6aeed" /f
if ($env:PROCESSOR_ARCHITECTURE -eq "AMD64") {
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\StrongName\Verification\Newtonsoft.Json,30ad4fe6b2a6aeed" /f
}
Run as administrator. Example shows how to reenable verification for Newtonsoft.Json
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\StrongName\Verification\Newtonsoft.Json,30ad4fe6b2a6aeed" /f
if ($env:PROCESSOR_ARCHITECTURE -eq "AMD64") {
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\StrongName\Verification\Newtonsoft.Json,30ad4fe6b2a6aeed" /f
}