agentleFS
ericwood8ericwood8/skills/bannerlord-decompile/SKILL.md

bannerlord-decompile

Skill1 starsChanged 14 days agoMITView on GitHub

Use when asked to decompile a Mount & Blade II Bannerlord mod, inspect what a compiled Bannerlord mod DLL does, patch or recompile a mod without its source, or look up a TaleWorlds.* API signature from the installed game assemblies. Trigger words - ilspycmd, ILSpy, BUTR reference assemblies, TaleWorlds, Bannerlord mod DLL.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If the user already has the ILSpy GUI app installed, install the matching version (check AppData\Local\Programs\ILSpy\ILSpy.exe's file …

    line 14
  2. Very specific:

    Never: look for TaleWorlds.* on NuGet — it's the game's own proprietary code, never published there.

    line 41
  3. Very specific:

    If the mod is split across sibling DLLs (e.g.

    line 56

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Bannerlord Mod Decompiling (ILSpy / ilspycmd)

Setup

dotnet tool install -g ilspycmd

If the user already has the ILSpy GUI app installed, install the matching version (check AppData\Local\Programs\ILSpy\ILSpy.exe's file version) so output is consistent.

Decompiling

Full compilable project (one .cs file per type) — the default for recompiling:

ilspycmd "<dll>" -o "<outdir>" -p

For quick lookups without a full decompile:

ilspycmd "<dll>" -t "Fully.Qualified.TypeName"      # decompile just one type
ilspycmd "<dll>" --dump-table TypeDef | grep -i Foo # RELIABLE type/nested-type existence check
ilspycmd "<dll>" --dump-table TypeRef               # which external assembly a type comes from
ilspycmd "<dll>" --dump-table AssemblyRef           # every assembly + version the DLL references

-l c,i,s,d,e (list classes/interfaces/structs/delegates/enums) is faster to type but gave false negatives in practice — when a -l search comes up empty and you need to be sure a type doesn't exist, confirm with --dump-table TypeDef before concluding anything (e.g. before telling the user an API "doesn't exist in this game version").

Getting a decompiled Bannerlord project to compile again

  • Never look for TaleWorlds.* on NuGet — it's the game's own proprietary code, never published there. Reference the BUTR community's Bannerlord.ReferenceAssemblies.Core package instead, pinned to the actual installed game version: Version="<gameVersion>.*-*" (e.g. 1.4.8.*-*). One "Core" package bundles nearly everything a typical mod needs — confirmed to include TaleWorlds.CampaignSystem(.ViewModelCollection), TaleWorlds.MountAndBlade, TaleWorlds.GauntletUI*, TaleWorlds.Core*, TaleWorlds.Library, TaleWorlds.TwoDimension, TaleWorlds.Localization, TaleWorlds.ObjectSystem, etc. It is not split per game module.
  • These reference assemblies are compile-time-only stubs (every method body is throw null;) — fine to compile against, useless for reading real logic. To see actual behavior, decompile the real assembly from the game's own bin\Win64_Shipping_Client folder instead.
  • dotnet new install Bannerlord.Templates + dotnet new create blmodfx --name X ... scaffolds a known-good reference project fast (Harmony + reference-assemblies wiring already correct) — use the explicit create subcommand; the bare dotnet new blmodfx ... shorthand failed on the .NET 10 SDK. Likewise dotnet new sln on that SDK defaults to a .slnx file, not .sln — dotnet sln x.slnx add <csproj>... still works normally.
  • If the mod is split across sibling DLLs (e.g. Foo.dll + Foo.Core.dll), wire a real <ProjectReference> between their two decompiled .csproj files. Don't leave a <Reference><HintPath> pointing at the old original DLL — edits to the sibling project would then be silently ignored on rebuild.
  • Nullable/init-accessor polyfill files (System.Diagnostics.CodeAnalysis.*, System.Runtime.CompilerServices.IsExternalInit) sometimes appear as extra loose decompiled .cs files. Delete them before re-adding the Nullable/IsExternalInit NuGet packages for <Nullable>enable</Nullable> support, or you'll get duplicate-type errors.

Fixing invalid C# that ilspycmd emits

ilspycmd's output is not always valid, compilable C# as-is — it has several systematic decompiler artifacts. See ARTIFACTS.md for the checklist and fix pattern for each (ref-casts, _002Ector, protected-member access through a cast, unqualified nested types, and more) before assuming a decompile error is a real bug in the mod.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.