Linux 上的 ildasm 通过 nuget 安装:找不到 ildasm 可执行文件

ildasm on Linux via nuget installation: ildasm executable not found

我通过

在我的 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/

但其中 none 包含任何 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 时做错了什么?

让我们考虑两种安装方式ildasm

使用 nuget 包

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

# execution result
..
Runtime Environment:
 OS Name:     ubuntu
 OS Version:  18.04
 OS Platform: Linux
 RID:         ubuntu.18.04-x64 # <----
..
  • 下载包 运行time.{RID}.Microsoft.NETCore.ILDAsm。对于我的情况是:runtime.ubuntu.18.04-x64.Microsoft.NETCore.ILDAsm
  • 解压缩并提取可执行文件'/运行次/{RID}/native/ildasm'
  • 授予它执行权限并复制到 .NET 运行time 文件夹(调用 dotnet --list-运行times 列出 运行次)
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