如何在Linux中获取.Net文件的AssemblyVersion

Fre*_*ddy 20 .net linux mono assemblyinfo

有没有办法在不使用mono的情况下在Linux中获取.Net可执行文件的AssemblyVersion?我想要的是一个脚本或命令,让我在Linux机器上获得AssemblyVersion.我试过了:

#strings file.exe | grep AssemblyVersion
Run Code Online (Sandbox Code Playgroud)但它只是字符串而不是数字.还检查:
#file file.exe
Run Code Online (Sandbox Code Playgroud) 但只有一般信息.

有任何想法吗?

Fré*_*idi 11

尝试匹配跨越整行的版本号:

$ strings file.exe | egrep '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'
Run Code Online (Sandbox Code Playgroud)

在我的(少数)测试中,AssemblyVersion二进制文件总是最后的结果.

  • 在strings命令上使用`-el`将字符串解释为unicode。 (2认同)

vul*_*ven 11

另一种选择是使用exiftool,如下所示:

$ exiftool -AssemblyVersion -ProductVersion ./System.Private.CoreLib.dll
Assembly Version                : 7.0.0.0
Product Version                 : 7.0.4+0a396acafe9a7d46bce11f4338dbb3dd0d99b1b4
Run Code Online (Sandbox Code Playgroud)

  • 这很荒谬,但 exiftool 实际上可以读取 dotnet 程序集信息!它还读取其他属性。而且 `exiftool ./System.Private.CoreLib.dll` 比使用 monodis 简单得多。更不用说微软自己的dotnet-ildasm了。感谢@vulcan-raven 和 exiftool 的开发人员。 (2认同)

Jac*_*hee 10

根据Jb Evain的建议,您可以使用Mono反汇编程序.

monodis --assembly file.exe | grep Version
Run Code Online (Sandbox Code Playgroud)


Ott*_*o G 5

ikdasm同样随 Mono 一起分发的工具比 更强大monodis,不幸的是,它在许多 DLL 文件上崩溃并显示消息“分段错误:11”。维护者明确建议使用ikdasm而不是monodishttps://github.com/mono/mono/issues/8900#issuecomment-428392112

用法示例(使用当前无法处理的程序集monodis):

ikdasm -assembly System.Runtime.InteropServices.RuntimeInformation.dll | grep Version:
Run Code Online (Sandbox Code Playgroud)