Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# commandline decompiler

Tags:

c#

decompiler

I'm looking to decompile a lot of assemblies into C#. I found several tools that do a visual decompile. However I was wondering if there is a tool that can do decompiling from the command line (similar to ildasm /OUT).

The motivation is that there are 100+ of assemblies and I don't want to open each one and save as an .cs file. .NET Reflector seems to have a batch load of assemblies, but it doesn't have a batch save. So I was thinking of writing a script that goes through each assembly and decompiles it using a command line command.

like image 790
user1042466 Avatar asked Oct 24 '22 19:10

user1042466


2 Answers

If you are looking to have a program that generates the C# code for an assembly, Jon Gallant recently had a blog post about doing this using JustDecompile from Telerik. There are a couple of assemblies that you link to and then you can control the generation of the code without a UI.

like image 196
Adam Gritt Avatar answered Nov 15 '22 05:11

Adam Gritt


The only thing you need is this open source decompiler called dnSpy -> https://github.com/0xd4d/dnSpy

includes a command line tool:

Examples:
  dnSpy.Console.exe -o C:\out\path C:\some\path
      Decompiles all .NET files in the above directory and saves files to C:\out\path
  dnSpy.Console.exe -o C:\out\path -r C:\some\path
      Decompiles all .NET files in the above directory and all sub directories
  dnSpy.Console.exe -o C:\out\path C:\some\path\*.dll
      Decompiles all *.dll .NET files in the above directory and saves files to C:\out\path
  dnSpy.Console.exe --md 0x06000123 file.dll
      Decompiles the member with token 0x06000123
  dnSpy.Console.exe -t system.int32 --gac-file "mscorlib, Version=4.0.0.0"
      Decompiles System.Int32 from mscorlib
like image 27
Christian Casutt Avatar answered Nov 15 '22 07:11

Christian Casutt