.net - Linux 上的 ildasm 通过 nuget 安装 : ildasm executable not found

标签 .net linux nuget nuget-package ildasm

我通过以下方式在 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/

相关文章:

c# - Exception.ToString()上的OutOfMemory异常

c# - 为什么这个 reqpro40.applicationclass 实例创建失败?

c# - MongoDB:在 C# 驱动程序中构建查询

linux - 我无法禁用 nouveau 视频驱动程序

visual-studio - 术语 'nuget' 无法识别

.net - LinkedList 上的 LINQ - 迭代 LinkedListNode<T>,而不是 T

python - 权限被拒绝在 linux 中使用 shebang 行运行 python 脚本

linux - Debian 操作系统内核版本差异 : 3. 16.51-3 vs 3.16.51-3+deb8u1

.net - 添加 NuGet 包失败

.net - 如何使用程序集中的版本号创建预发布的 nuget 包