在 Linux 上获取 .NET Core DLL 版本 [英] Get .NET Core DLL version on Linux

查看:65
本文介绍了在 Linux 上获取 .NET Core DLL 版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 .NET Core 应用程序,它在构建期间使用 .csproj 中的标准选项设置元数据属性:

I have a .NET Core app which sets metadata properties during build, using standard options in the .csproj:

<Project>

  <PropertyGroup>

    <Product>MyCoolProduct</Product> 
    <Version>0.1.1</Version>

  </PropertyGroup>

  <snip />

</Project>

在 Windows 上,这很容易在资源管理器中或通过 PowerShell 脚本从编译的 .dll 中检索.我如何在 Linux 上做类似的事情?理想情况下,我希望能够运行一个简单的命令,例如 dotnet inspect my.dll 并获取该程序集的元数据摘要,但接下来最好的事情是什么?

On Windows, this is easy enough to retrieve from the compiled .dll either in Explorer, or via a PowerShell script. How can I do something similar on Linux? Ideally, I'd like to be able run a simple command like dotnet inspect my.dll and get a summary of metadata for that assembly, but what's the next best thing?

推荐答案

我使用 exiftool:

$ exiftool /usr/lib64/dotnet/sdk/2.0.3/Microsoft/Microsoft.NET.Build.Extensions/tools/netcoreapp1.0/System.Threading.dll | grep -i version
ExifTool Version Number         : 10.55
Linker Version                  : 48.0
OS Version                      : 4.0
Image Version                   : 0.0
Subsystem Version               : 4.0
File Version Number             : 4.6.24705.1
Product Version Number          : 0.0.0.0
File Version                    : 4.6.24705.01
Product Version                 : 4.6.24705.01. Commit Hash: 4d1af962ca0fede10beb01d197367c2f90e92c97
Assembly Version                : 4.0.12.0

最初发现于这里.

不过要小心.它不适用于 crossgened 的东西:

Watch out, though. It doesn't work on crossgened stuff:

$ exiftool /usr/lib64/dotnet/sdk/2.0.3/Roslyn/Microsoft.CodeAnalysis.dll
ExifTool Version Number         : 10.55
File Name                       : Microsoft.CodeAnalysis.dll
Directory                       : /usr/lib64/dotnet/sdk/2.0.3/Roslyn
File Size                       : 4.6 MB
File Modification Date/Time     : 2018:01:24 13:12:48-05:00
File Access Date/Time           : 2018:02:01 12:37:59-05:00
File Inode Change Date/Time     : 2018:01:26 09:52:23-05:00
File Permissions                : rw-r--r--
Error                           : File format error

这篇关于在 Linux 上获取 .NET Core DLL 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆