Debugging your mods in Visual Studio - piotrulos/MSCModLoader GitHub Wiki
Prepare for debugging
To start you need installed MSCLoader, 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 MSCLInstaller. Open MSCLInstaller and on selection screen click "Show Advanced Options".
- If you see above screen, click "Enable Debbuging"
- 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.
- Sometimes you need to restart your PC to get next step to work
Debugging with breakpoints
- Set your project to
Debug
(remember to useRelease
when you ready to publish your mod)
- 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 toBuild Events
and in second window paste this:
- Go to
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 IP127.0.0.1:56000
(auto-filled IP should also work) and press OK
- Now play the game until you hit your 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.