Currently suffering from DLL hell, I'd like to write a PowerShell script to check version numbers for the DLLs that a Visual Studio project references. Does anyone know where the "Version" property comes from for such a DLL?
Example:
Here's the Visual Studio properties pane for a reference in my project to System.Net.Http:
I can't figure out how to read that Version property programmatically.
In PowerShell, if I try (get-item <filepath>).VersionInfo I see a FileVersion and a ProductVersion which seem to relate to the version of .NET:
PS C:\temp> (get-item $file).VersionInfo.ToString()
File: C:\Working\...\packages\System.Net.Http.4.3.2\lib\net46\System.Net.Http.dll
InternalName: System.Net.Http.dll
OriginalFilename: System.Net.Http.dll
FileVersion: 4.6.25220.01
FileDescription: System.Net.Http
Product: Microsoft® .NET Framework
ProductVersion: 4.6.25220.01. Commit Hash: 936d52df0532d56a19ff8486bc9aa7eac19860b3
Debug: False
Patched: False
PreRelease: False
PrivateBuild: False
SpecialBuild: False
Language: Language Neutral
I tried using reflection to look at the assembly, and that gave me the runtime version:
PS C:\temp> $assembly = [Reflection.Assembly]::Loadfile($file)
PS C:\temp> $assembly.ImageRuntimeVersion
v4.0.30319
Then I tried looking at the Version in the AssemblyName:
PS C:\temp> $assemblyName = $assembly.GetName()
PS C:\temp> $assemblyName.Version.ToString()
4.0.0.0
None of them match up with the Version in the Visual Studio Properties pane.
