home / skills / aaronontheweb / dotnet-skills / ilspy-decompile

ilspy-decompile skill

/skills/ilspy-decompile

This skill decompiles .NET assemblies with ILSpy to reveal implementation details, aiding understanding, debugging, and auditing library behavior.

npx playbooks add skill aaronontheweb/dotnet-skills --skill ilspy-decompile

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
2.1 KB
---
name: ilspy-decompile
description: Understand implementation details of .NET code by decompiling assemblies. Use when you want to see how a .NET API works internally, inspect NuGet package source, view framework implementation, or understand compiled .NET binaries.
allowed-tools: Bash(dnx:*)
---

# .NET Assembly Decompilation with ILSpy

Use this skill to understand how .NET code works internally by decompiling compiled assemblies.

## Prerequisites

- .NET SDK installed
- ILSpy command-line tool available via one of the following:
  - `dnx ilspycmd` (if available in your SDK or runtime)
  - `dotnet tool install --global ilspycmd`

Both forms are shown below. Use the one that works in your environment.

> Note: ILSpyCmd options may vary slightly by version.  
> Always verify supported flags with `ilspycmd -h`.

## Quick start

```bash
# Decompile an assembly to stdout
ilspycmd MyLibrary.dll
# or
dnx ilspycmd MyLibrary.dll

# Decompile to an output folder
ilspycmd -o output-folder MyLibrary.dll
```

## Common .NET Assembly Locations

### NuGet packages

```bash
~/.nuget/packages/<package-name>/<version>/lib/<tfm>/
```

### .NET runtime libraries

```bash
dotnet --list-runtimes
```

### .NET SDK reference assemblies

```bash
dotnet --list-sdks
```

> Reference assemblies do not contain implementations.

### Project build output

```bash
./bin/Debug/net8.0/<AssemblyName>.dll
./bin/Release/net8.0/publish/<AssemblyName>.dll
```

## Core workflow

1. Identify what you want to understand
2. Locate the assembly
3. List types
4. Decompile the target

## Commands

### Basic decompilation

```bash
ilspycmd MyLibrary.dll
ilspycmd -o ./decompiled MyLibrary.dll
ilspycmd -p -o ./project MyLibrary.dll
```

### Targeted decompilation

```bash
ilspycmd -t Namespace.ClassName MyLibrary.dll
ilspycmd -lv CSharp12_0 MyLibrary.dll
```

### View IL code

```bash
ilspycmd -il MyLibrary.dll
```

## Notes on modern .NET builds

- ReadyToRun images may reduce readability
- Trimmed or AOT builds may omit code
- Prefer non-trimmed builds

## Legal note

Decompiling assemblies may be subject to license restrictions.

Overview

This skill helps you inspect compiled .NET binaries by decompiling assemblies with ILSpy. It lets you read C# or IL output, explore types and members, and extract project-like source for analysis or debugging. Use it to learn implementation details, audit third-party packages, or recover lost source for investigation.

How this skill works

The skill runs the ILSpy command-line tool (ilspycmd or dnx ilspycmd) against target DLLs or EXEs. It can print decompiled code to stdout, write a decompiled project folder, or target specific types, languages, or IL output. The workflow is: locate the assembly, list available types, and run targeted or full decompilation with appropriate flags.

When to use it

  • You want to inspect how a NuGet package implements an API without source access.
  • You need to debug or understand behavior in a compiled dependency.
  • You want to review framework or runtime implementations shipped in .NET runtimes.
  • You need to recover logic from a compiled build when source is missing.
  • You’re auditing compiled binaries for security or licensing concerns.

Best practices

  • Prefer non-trimmed, non-AOT builds for more readable decompiled output.
  • Verify the ilspycmd version and supported flags with ilspycmd -h before use.
  • Use -o to export a project folder when you want to navigate multiple types.
  • Target specific types with -t to reduce noise and speed up inspection.
  • Be mindful of license and legal restrictions before decompiling third-party assemblies.

Example use cases

  • Decompile a NuGet package assembly from ~/.nuget/packages to inspect an internal helper method.
  • Run ilspycmd -o ./decompiled MyLibrary.dll to get a browsable project for code review.
  • Use ilspycmd -il MyRuntimeLib.dll to view the IL when investigating performance or JIT behavior.
  • Target a class with ilspycmd -t Namespace.ClassName to focus on a single implementation detail.

FAQ

Do I need the .NET SDK installed?

Yes. The .NET SDK is required to run ilspycmd or dnx ilspycmd and to locate runtime or build outputs.

Why is some decompiled code incomplete or missing?

Trimmed, AOT, or ReadyToRun builds can remove or alter code, reducing readability. Prefer full framework or debug builds for best results.