Debugging your mods in Visual Studio - piotrulos/MSCModLoader GitHub Wiki

[!IMPORTANT] Below debug method works on version 1.3.4 build 360 and Doorstop 4.4.0 (or newer)
Old version is here > Debugging your mods in Visual Studio (old)

Prepare for debugging

To start you need to have installed MSCLoader first, installed visual studio with unity debugger (if you install using tutorial on this wiki, you mostly have this, check if you have Debug > Attach unity debugger option in VS menu)

  • Make sure you are on Doorstop 4.4.0 if not fully update MSCLoader using MSCLInstaller. (Below method will just crash game on older version of doorstop)
    You can check version at the bottom of MSCLoader settings
  • Open MSCLInstaller and on selection screen click "Show Advanced Options". Click "Copy debug files" to copy debug symbols converter script to Mods folder. (if you have old debug files it will say first to disable old debug)
  • To enable debugging just launch game with this launch parameters --doorstop-mono-debug-enabled true --doorstop-mono-debug-address 127.0.0.1:56000 or click here to launch it from browser or create shortcut with this steam url
    steam://run/516750//--doorstop-mono-debug-enabled true --doorstop-mono-debug-address 127.0.0.1:56000

Debugging with breakpoints

  • Set your project to Debug (remember to use Release when you ready to publish your mod)
    Debug
  • Compile your mod, and copy YourMod.dll and YourMod.pdb to mods folder.
  • Run included debug.bat folder in your mods folder.
  • You can automate this process by using "post-build event command line" in visual studio
    • Go to Project > YourMod Properties... (last option) then go to Build Events and in second window paste this:
if "$(ConfigurationName)" == "Debug" (
copy "$(TargetPath)" "D:\Steam\steamapps\common\My Summer Car\Mods" /y
copy "$(TargetDir)$(TargetName).pdb" "D:\Steam\steamapps\common\My Summer Car\Mods" /y
cd "D:\Steam\steamapps\common\My Summer Car\Mods"
call "D:\Steam\steamapps\common\My Summer Car\Mods\debug.bat"
) ELSE (
copy "$(TargetPath)" "D:\Steam\steamapps\common\My Summer Car\Mods" /y
)

(Of course replace D:\Steam\steamapps\common\My Summer Car\Mods with your Mods path.)

  • You can automate this process further by using "Start browser with URL"
    • Go to "Project > YourMod Properties..." (last option) then go to "Debug" under "Start Action" (at the top) go to "Start browser with URL" and paste this:
steam://run/516750//--doorstop-mono-debug-enabled true --doorstop-mono-debug-address 127.0.0.1:56000
  • This will run the game after building and coping files to Mods directory.
  • Now set some breakpoints run MSC and in VS go to Debug > Attach Unity Debugger
  • In new window click Input IP and type IP 127.0.0.1:56000 (auto-filled IP should also work) and press OK
    IP
  • Now play the game until you hit your breakpoint
    breakpoint
  • Now you can view variables and other values in real-time. To unfreeze game click continue in visual studio until you left all your breakpoints.