我通过以下方式在 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 时做错了什么?
最佳答案
让我们考虑两种安装 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 # <----
..
- 下载运行时包。{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}/
- 创建符号链接(symbolic link)
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
关于.net - Linux 上的 ildasm 通过 nuget 安装 : ildasm executable not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59595350/