2

我通过在我的 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 做错了什么?

4

1 回答 1

2

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

使用 nuget 包

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

# execution result
..
Runtime Environment:
 OS Name:     ubuntu
 OS Version:  18.04
 OS Platform: Linux
 RID:         ubuntu.18.04-x64 # <----
..
  • 下载包运行时。{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
于 2020-12-29T02:28:50.320 回答