2

I installed ildasm on my Ubuntu 18.04 via

nuget install Microsoft.NETCore.ILDAsm

I somehow ended up with two directories:

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

but none of them contained any dll or 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

Where did nuget put the main application, i.e. the equivalent to the ildasm.exe on Windows?

Or am I doing something wrong to install ildasm on Linux?

langlauf.io
  • 3,009
  • 2
  • 28
  • 45
  • You should use the global tool version, https://www.nuget.org/packages/dotnet-ildasm/ – Lex Li Jan 04 '20 at 23:19
  • @LexLi I am not sure if this version is really the same as the "original" Microsoft ildasm.exe. The global tools version says "dotnet ildasm 0.12.2.0" and the other one is version 2.0.8. – langlauf.io Jan 05 '20 at 12:21
  • 1
    The NuGet package you used was never documented to be the right thing to use. For years, Microsoft didn't really have a tool for cross platform, https://github.com/dotnet/cli/issues/6223 So that third party global tool can be the best option at this moment. – Lex Li Jan 05 '20 at 19:17

1 Answers1

2

Let's consider two ways to install ildasm.

Using nuget-package

  • define RID (Runtime Identifier)
dotnet --info

# execution result
..
Runtime Environment:
 OS Name:     ubuntu
 OS Version:  18.04
 OS Platform: Linux
 RID:         ubuntu.18.04-x64 # <----
..
  • download the package runtime.{RID}.Microsoft.NETCore.ILDAsm. For my case it is: runtime.ubuntu.18.04-x64.Microsoft.NETCore.ILDAsm
  • unarchive it and extract executable file '/runtimes/{RID}/native/ildasm'
  • grant it execution permission and copy to .NET runtime folder (call dotnet --list-runtimes to list runtimes)
chmod +x ildasm
sudo mv ildasm /usr/share/dotnet/shared/Microsoft.NETCore.App/{version}/
  • create symlink
ln -s /usr/share/dotnet/shared/Microsoft.NETCore.App/{version}/ildasm ildasm
  • run ildasm
./ildasm {path}/project.dll >> {path}/project.il

The same steps are applicable for ilasm.

Using dotnet-ildasm tool

# 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

Output IL to file:

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

dotnet ildasm program.dll -o program.il
vladimir
  • 13,428
  • 2
  • 44
  • 70
  • `dotnet-ildasm` is a completely different implementation of a .NET disassembler, and does not share code with the Microsoft tool `ildasm`. – Vladimir Panteleev Oct 31 '21 at 17:16
  • This package has been deprecated as part of the .NET Package Deprecation effort. Does this mean that its use may not work as intended? (https://github.com/dotnet/announcements/issues/217) – Miguel Cardoso Jan 02 '23 at 18:54