Search code examples
c#.netvisual-studiodisassemblydecompiling

How to disassemble single file .NET exes, or extract the .dll from them?


I'm have some .NET exes built with the single file option (https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file) and I need to use a disassembler on them, but none of the disassembly tools (e.g. dnspy, ilspy, ildasm, etc.) work since these are actually native binaries with .NET assembly embedded in them, as explained in the Microsoft docs.

E.g., trying ildasm on these binaries outputs error: 'example.exe' has no valid CLR header and cannot be disassembled

How can I extract the .NET dlls from these single file exes so that I can disassemble them? Or is there any other way to disassemble these .NET single file exes?


Solution

  • ILSpy 7.0 supports .NET 5 single-file bundles.

    ILSpy 7.1 adds support for .NET 6 bundles (added compression support).

    ILSpy 7.2 also allows saving the embedded .dlls ("Extract package entry" in context menu).

    If you're looking for a command-line tool, see https://www.nuget.org/packages/sfextract/