From the command line (or by any means really), how can I determine which CLR version a .NET assembly requires?
I need to determine if an assembly requires 2.0 or 4
Here is a powershell one liner that will display the Target framework version for assemblies targeting v4 and up.
Resolve-Path($args) | Select @{N='Assembly'; E={$_ }}, @{N='TargetFramework'; E={(([Reflection.Assembly]::ReflectionOnlyLoadFrom($_).GetCustomAttributesData() | Where-Object { $_.AttributeType -like "System.Runtime.Versioning.TargetFrameworkAttribute" })).NamedArguments.TypedValue}} | Format-Table
use:
C:\test\> show-targetfw.ps1 *.dll
Assembly TargetFramework
-------- --------
C:\test\a.dll ".NET Framework 4.6.1"
C:\test\b.dll ".NET Framework 4.5.2"