Skip to content

Debugging your mods in Visual Studio

piotrulos edited this page Mar 8, 2020 · 17 revisions

Prepare for debugging

To start you need installed MSCLoader 0.4 or later, 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)

  • First you need to enable debugging in MSCPatcher. Open MSCPatcher and go to settings tab.
    Debugging
  • Check that you understad what is debugging and press Enable Debugging
  • Say YES to UAC prompt and in windows console screen press any key if prompted.
  • You should get this message if everything you did right.
    good
  • Sometimes you need to restart your PC to get next step to work

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://rungameid/516750
  • 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.
Clone this wiki locally