5

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
user1042466
  • 51
  • 1
  • 2

3 Answers3

2

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
Christian Casutt
  • 2,334
  • 4
  • 29
  • 38
2

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.

rraallvv
  • 2,875
  • 6
  • 30
  • 67
Adam Gritt
  • 2,654
  • 18
  • 20
1

Just as a continuation of the answer from above, dnSpy seems to be discontinued and crashed for me when I tried to use it (like here).

Maybe consider using dnSpyEx, which worked like a charm.

Abb4
  • 48
  • 4