Is there a Microsoft tool to get the assembly version of a DLL file from a command line?
(I know that I can code my own tool.)
Wow this is bad considering things like old exploitable gdiplus.dll's floating around.
My solution is simple. batch file programming.
This puts an nfo file in the same dir with the version
You can GET filever.exe, which can be downloaded as part of the Windows XP SP2 Support Tools package - only 4.7MB of download.
adobe_air_version.bat
c:\z\filever.exe /A /D /B "C:\Program Files\Common Files\Adobe AIR\Versions\1.0\Adobe AIR.dll" >000_adobe_air.dll_VERSION.nfo
exit
Variation.
Get all the versions in a directory to a text file.
c:\z\filever.exe /A /D /B "c:\somedirectory\ *.dll *.exe >000_file_versions.nfo
exit
There's also Sigcheck by systernals.
http://technet.microsoft.com/en-us/sysinternals/bb897441.aspx
Do you use GACUTIL?
You can get the assembly version from this command below.
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\gacutil.exe /L "<your assembly name>"
In Powershell
$version = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("filepath.exe").FileVersion.ToString()
If you use mono and linux, try this:
monodis --assembly MyAssembly.dll
find . -name MyAssembly.dll -exec monodis --assembly {} ';' | grep Version
This is an area where PowerShell shines. If you don't already have it, install it. It's preinstalled with Windows 7.
Running this command line:
[System.Reflection.Assembly]::LoadFrom("C:\full\path\to\YourDllName.dll").GetName().Version
outputs this:
Major Minor Build Revision
----- ----- ----- --------
3 0 8 0
Note that LoadFrom returns an assembly object, so you can do pretty much anything you like. No need to write a program.
For those, like I, who come looking for such a tool:
using System;
using System.IO;
using System.Reflection;
class Program
{
public static void Main(string[] args)
{
foreach (string arg in args)
{
try
{
string path = Path.GetFullPath(arg);
var assembly = Assembly.LoadFile(path);
Console.Out.WriteLine(assembly.GetName().FullName);
}
catch (Exception exception)
{
Console.Out.WriteLine(string.Format("{0}: {1}", arg, exception.Message));
}
}
}
}