Skip to content

How to debug RimWorld from Visual Studio

Mhburg edited this page Apr 18, 2020 · 15 revisions

Environment: Visual Studio Community 2019+, Unity Tools for Visual Studio

Steps

  1. Install Visual Studio Community 2019 or better and choose workload for developing with Unity. If VS is already installed, please refer to Visual Studio tool for Unity
  2. Download Unity-debugging-2019.x.zip from dnSpy. More information can be found on its wiki.
  3. Backup RimWorld folder. More specifically, backup the dll below,
 πŸ“---Installation_path_of_RimWorld
 |    πŸ“---RimWorld
 |         πŸ“---MonoBleedingEdge
 |              πŸ“---EmbedRuntime
 |                   βš™οΈ---mono-2.0-bdwgc.dll  
  1. Unzip the file from dnSpy, copy the mono-2.0-bdwgc.dll in folder unity-2019.1.8 or newer version and drop it in the directory in step 3 to replace the vanilla one.
  2. Add RimWorld.exe as an existing project to solution as such.
  3. Right click on the added RimWorld.exe and add environment variable
    Variable=dnspy_unity_dbg2, Value=--debugger-agent=transport=dt_socket,server=y,address=127.0.0.1:56000,suspend=y,no-hide-debugger. And set it as the startup project via the right-click context menu.
  4. Update the build information of your project and have it produce "Portable" debugging information. Example
  5. Almost there. Now, build the solution, start it without debugging. The default hotkey is "Ctrl+F5". And nothing will happen until a unity debugger is attached. Press "Attach Unity Debugger", click "Input IP" on the pop up window and "OK". RimWorld now will spin up with a debugger attached. Example

Tips

  • Don't forget to build your solution and copy the pdb files along with the dll files to mod folders.