Assembly version from command line?

2019-01-21 09:00发布

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.)

9条回答
forever°为你锁心
2楼-- · 2019-01-21 09:19

File Version tool will help:

filever /V YourDllName.dll
查看更多
▲ chillily
3楼-- · 2019-01-21 09:20

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 returnes an assembly object, so you can do pretty much anything you like. No need to write a program.

查看更多
▲ chillily
4楼-- · 2019-01-21 09:20

If you use mono and linux, try this:

monodis --assembly MyAssembly.dll

find . -name MyAssembly.dll -exec monodis --assembly {} ';' | grep Version 
查看更多
Explosion°爆炸
5楼-- · 2019-01-21 09:22

Adding some sugar to the other powershell-ish answers...

To get extended properties like 'FullName'

$dllPath = "C:\full\path\to\YourDllName.dll";
$ass  = [System.Reflection.Assembly]::LoadFrom($dllPath);
$ass.GetName();
$ass
查看更多
SAY GOODBYE
6楼-- · 2019-01-21 09:24

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

查看更多
来,给爷笑一个
7楼-- · 2019-01-21 09:30

In Powershell

$version = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("filepath.exe").FileVersion.ToString()
查看更多
登录 后发表回答