-
Notifications
You must be signed in to change notification settings - Fork 564
dnSpy Debugging
Due to the in-memory patching introduced in BepInEx 4.0, it is not possible to use dnSpy to debug plugins with the base installation of BepInEx. Instead, the developers must use the modified BepInEx.Patcher.exe
.
NOTE
The dnSpy-compatible BepInEx patcher does not support in-memory preloader patchers!
Thus, you can only debug normal plug-ins.
The permanent assembly patcher for BepInEx is provided as a separate download in the Bleeding Edge builds. In order to use the dnSpy debugger functionality, you must apply the hardpatch to the game.
To set up BepInEx to work with dnSpy debugger, do the following:
-
Download the base BepInEx build and the BepInEx patcher (from releases, Bleeding Edge builds) or build them yourself.
-
Install base BepInEx as per the installation guide.
-
Place
BepInEx.Patcher.exe
into the game's root folder -
Run
BepInEx.Patcher.exe
(ormono BepInEx.Patcher.exe
if you are on Linux/macOS). This will patch game'sUnityEngine.dll
and placeBepInEx.Bootstrap.dll
into the game'sManaged
folder. -
Modify
doorstop_config.ini
as follows:enabled=false
- Download the latest version of dnSpy and an appropritate version of Unity-debugging package
- From the downloaded Unity-debugging package, pick
mono.dll
that corresponds to the version of the game you want to debug and replace the game's originalmono.dll
with it - Open dnSpy and open the plugin DLL (from
BepInEx
folder) you want to debug. Additionally, open game's own assemblies to debug (fromManaged
folder) - Set up appropriate breakpoints
- Open
Debug > Start Debugging
dialogue - Select
Unity
as the Debug engine, select the game's EXE (not the launcher) and press OK to start debugging
If everything worked correctly, dnSpy will not time out in 30 seconds (or in whatever timeout time you configured) and will break on any breakpoint you set.
When you don't want to debug anymore, you can revert back to the original game installation as follows:
-
Restore
mono.dll
to the original version -
From every
Managed
folder found in the game's root (or its subfolders), removeBepInEx.Bootstrap.dll
and restoreUnityEngine.dll.bak
-
Edit
doorstop_config.ini
as follows:enabled=true