【问题标题】:ildasm on Linux via nuget installation: ildasm executable not foundLinux 上的 ildasm 通过 nuget 安装:找不到 ildasm 可执行文件
【发布时间】:2020-04-23 00:11:33
【问题描述】:

我通过

在我的 Ubuntu 18.04 上安装了 ildasm
nuget install Microsoft.NETCore.ILDAsm

不知何故,我最终得到了两个目录:

/home/vagrant/.nuget/packages/microsoft.netcore.ildasm/2.0.8/
/home/vagrant/Microsoft.NETCore.ILDAsm.2.0.8/

但它们都不包含任何 dll 或 exe:

vagrant@ubuntu1804:~/Microsoft.NETCore.ILDAsm.2.0.8$ ls
LICENSE.TXT  Microsoft.NETCore.ILDAsm.2.0.8.nupkg
Microsoft.NETCore.ILDAsm.nuspec  _rels  runtime.json  THIRD-PARTY-NOTICES.TXT  
version.txt

nuget 将主应用程序放在哪里,即相当于 Windows 上的 ildasm.exe?

还是我在 Linux 上安装 ildasm 做错了什么?

【问题讨论】:

  • 你应该使用全局工具版本,nuget.org/packages/dotnet-ildasm
  • @LexLi 我不确定这个版本是否真的与“原始”Microsoft ildasm.exe 相同。全局工具版本说“dotnet ildasm 0.12.2.0”,另一个是版本 2.0.8。
  • 您使用的 NuGet 包从未被证明是正确的使用方法。多年来,微软并没有真正的跨平台工具,github.com/dotnet/cli/issues/6223 所以此时第三方全球工具可能是最好的选择。

标签: .net linux nuget nuget-package ildasm


【解决方案1】:

让我们考虑两种安装ildasm的方法。

使用 nuget-package

  • 定义RID(运行时标识符)
dotnet --info

# execution result
..
Runtime Environment:
 OS Name:     ubuntu
 OS Version:  18.04
 OS Platform: Linux
 RID:         ubuntu.18.04-x64 # <----
..
  • 下载包runtime.{RID}.Microsoft.NETCore.ILDAsm。就我而言,它是:runtime.ubuntu.18.04-x64.Microsoft.NETCore.ILDAsm
  • 解压并解压可执行文件'/runtimes/{RID}/native/ildasm'
  • 授予它执行权限并复制到 .NET 运行时文件夹(调用 dotnet --list-runtimes 列出运行时)
chmod +x ildasm
sudo mv ildasm /usr/share/dotnet/shared/Microsoft.NETCore.App/{version}/
  • 创建符号链接
ln -s /usr/share/dotnet/shared/Microsoft.NETCore.App/{version}/ildasm ildasm
  • 运行 ildasm
./ildasm {path}/project.dll >> {path}/project.il

同样的步骤适用于ilasm

使用dotnet-ildasm 工具

# install .net core runtime if required
# sudo apt-get update; \
#   sudo apt-get install -y apt-transport-https && \
#   sudo apt-get update && \
#   sudo apt-get install -y dotnet-runtime-3.0

# find required tool
dotnet tool search ildasm
# output:
# Package ID         Latest Version      Authors      Downloads      Verified
# ---------------------------------------------------------------------------
# dotnet-ildasm      0.12.2              pjbgf        100154                 
# dotasm             1.0.1               DotAsm       434 

# install tool
dotnet tool install -g dotnet-ildasm

输出 IL 到文件:

# go to project folder
cd ../project/bin/Debug/netx.x

dotnet ildasm program.dll -o program.il

【讨论】:

  • dotnet-ildasm 是一个完全不同的 .NET 反汇编器实现,不与 Microsoft 工具 ildasm 共享代码。
猜你喜欢
  • 2017-01-16
  • 2020-05-27
  • 2012-03-09
  • 1970-01-01
  • 2021-10-27
  • 2017-02-21
  • 2019-10-04
  • 2013-11-26
  • 1970-01-01
相关资源
最近更新 更多