Is there the equivalent of ILDASM / ILASM for the .net-core?
Specifically, I\'m looking for something that runs on Linux (Hence why the .net-core).
It does not appear there is a native Microsoft tool that serves these functions on Linux and it is not currently built into the dot-net-core.
However, Mono allows the assembly and disassembly of IL code:
Installation Instructions can be found here.
What you are looking for is:
ilasm - For assembling
monodis - For disassembling
These are found in the package mono-utils:
e.g. On Debian 8 I did the following:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/debian jessie" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update
apt-get install mono-devel mono-utils
However, FYI, for those trying to create exports, Mono does not appear to handle the x64 export syntax.
Let's 'install' ildasm tool using related nuget-package:
dotnet --info
# execution result
..
Runtime Environment:
OS Name: ubuntu
OS Version: 18.04
OS Platform: Linux
RID: ubuntu.18.04-x64 # <----
..
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 {path}/project.dll >> {path}/project.il
The same steps are applicable for ilasm.
As an alternate way consider 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
This is not a full replacement for the tools mentioned in the other answers, but this F# snippet allowed me to quickly find the appropriate type & function name I needed for AWS Lambda:
open System.Reflection
[<EntryPoint>]
let main argv =
let asm =
argv
|> Array.tryHead
|> Option.map Assembly.LoadFrom
|> Option.defaultWith (Assembly.GetExecutingAssembly)
printfn "%s" asm.FullName
for t in asm.GetTypes () do
printfn " * %s" t.FullName
0
Both the ildasm and ilasm tools are built with CoreCLR from this repo: https://github.com/dotnet/coreclr. They include similar functionality as the versions shipped with Windows (sans GUI, etc.).
There are nuget packages shipped that include them as well (https://www.nuget.org/packages?q=ildasm), but they are platform-specific and also require a matching version of CoreCLR to use, so they are not straightforward to consume via nuget. The easiest way to run these on your platform is to just build them from source from the coreclr repo.