.net-core: Equivalent of ILDASM / ILASM

前端 未结 4 615
时光取名叫无心
时光取名叫无心 2021-02-05 15:05

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).

4条回答
  •  被撕碎了的回忆
    2021-02-05 15:31

    Let's 'install' ildasm tool using related 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.


    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
    

提交回复
热议问题