来自命令行的汇编版本?

发布于 2024-09-06 05:43:04 字数 70 浏览 3 评论 0原文

是否有 Microsoft 工具可以从命令行获取 DLL 文件的汇编版本?

(我知道我可以编写自己的工具。)

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

紙鸢 2024-09-13 05:43:04

这是 PowerShell 的大放异彩的领域。如果您还没有它,请安装它。它预装在 Windows 7 中。

运行此命令行:

[System.Reflection.Assembly]::LoadFrom("C:\full\path\to\YourDllName.dll").GetName().Version

输出:

Major  Minor  Build  Revision
-----  -----  -----  --------
3      0      8      0

请注意,LoadFrom 返回一个程序集对象,因此您几乎可以执行任何您喜欢的操作。无需编写程序。

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.

猫瑾少女 2024-09-13 05:43:04

如果您使用 mono 和 linux,请尝试以下操作:

monodis --assembly MyAssembly.dll

find . -name MyAssembly.dll -exec monodis --assembly {} ';' | grep Version 

If you use mono and linux, try this:

monodis --assembly MyAssembly.dll

find . -name MyAssembly.dll -exec monodis --assembly {} ';' | grep Version 
淡紫姑娘! 2024-09-13 05:43:04

对于那些像我一样正在寻找这样一个工具的人:

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));
            }
        }
    }
}

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));
            }
        }
    }
}
写下不归期 2024-09-13 05:43:04

在 Powershell 中

$version = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("filepath.exe").FileVersion.ToString()

In Powershell

$version = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("filepath.exe").FileVersion.ToString()
故事未完 2024-09-13 05:43:04

我使用所选的答案,直到出现以下错误
不应加载参考程序集
执行。它们只能在仅反射加载器上下文中加载。对于多个程序集,

使用

[System.Reflection.Assembly]::ReflectionOnlyLoadFrom("C:\full\path\to\YourDllName.dll").GetName().Version

应该在这些情况下工作(可能是所有情况)

I used the selected answer until I got the following error
Reference assemblies should not be loaded for
execution. They can only be loaded in the Reflection-only loader context.
for several assemblies

using

[System.Reflection.Assembly]::ReflectionOnlyLoadFrom("C:\full\path\to\YourDllName.dll").GetName().Version

should work in those cases (probably all cases)

音盲 2024-09-13 05:43:04

哇,考虑到诸如旧的可利用 gdiplus.dll 之类的东西,这很糟糕。

我的解决方案很简单。批处理文件编程。

这会将 nfo 文件与版本

You can GET filever.exe 放在同一目录中,该文件可以作为 Windows XP SP2 支持工具包的一部分进行下载 - 仅下载 4.7MB。

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

变体。

将目录中的所有版本获取到文本文件。

c:\z\filever.exe /A /D /B "c:\somedirectory\ *.dll *.exe >000_file_versions.nfo

exit

还有 systernals 的 Sigcheck。

http://technet.microsoft.com/en-us/sysinternals/bb897441.aspx

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

晒暮凉 2024-09-13 05:43:04

文件版本工具将帮助:

filever /V YourDllName.dll

File Version tool will help:

filever /V YourDllName.dll
梦言归人 2024-09-13 05:43:04

向其他类似 powershell 的答案添加一些糖...

以获得“FullName”等扩展属性

$dllPath = "C:\full\path\to\YourDllName.dll";
$ass  = [System.Reflection.Assembly]::LoadFrom($dllPath);
$ass.GetName();
$ass

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
メ斷腸人バ 2024-09-13 05:43:04

如果想要查看版本,我们可以使用以下命令

ildasm "<your assembly path>"  /TEX | find "AssemblyFileVersionAttribute"

这将返回一个如下所示的字符串
.custom 实例 void [mscorlib]System.Reflection.AssemblyFileVersionAttribute::.ctor(string) = ( 01 00 0E 32 32 2E 38 2E 38 32 37 30 2E 31 36 35 // ...22.8.8270.165

版本在评论中给出。

If the intention is to see the version, we can use the following command

ildasm "<your assembly path>"  /TEX | find "AssemblyFileVersionAttribute"

This return a string like the following
.custom instance void [mscorlib]System.Reflection.AssemblyFileVersionAttribute::.ctor(string) = ( 01 00 0E 32 32 2E 38 2E 38 32 37 30 2E 31 36 35 // ...22.8.8270.165

The version is given in the comment.

心凉怎暖 2024-09-13 05:43:04

您是否使用GACUTIL

您可以通过下面的命令获取程序集版本。

C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\gacutil.exe /L "<your assembly name>"

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>"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文