GarageGames / Torque2D

MIT Licensed Open Source version of Torque 2D game engine from GarageGames
MIT License
1.67k stars 1.56k forks source link

VisualStudio - Debug Working Directory #299

Closed chaigler closed 8 years ago

chaigler commented 8 years ago

Attempting to debug the engine from within VisualStudio will fail because the solution's "WorkingDirectory" property points to the wrong directory. The engine launches but is unable to find the main.cs file and so it immediately closes.

By default VS sets the WorkingDirectory to $(ProjectDir) but this actually needs to be $(OutputPath). Unfortunately these properties are stored per-user in the .user file VS creates when it first loads the solution. Apparently there's no way to change this without modifying the .user file. It seems the most we can do is update the wiki with instructions on setting up the solution so debugging works correctly.

Thoughts?

greenfire27 commented 8 years ago

I was able to fix it without changing the default options by dropping a main.cs file in engine/compilers/VisualStudio 2013/

The main.cs file contains this code:

// This file simply points to the real main.cs file in the root of the working directory.
// This is needed if the project run in debug mode from within VisualStudio.
exec("../../../main.cs");

I then had to change the path of the modules folder within the main.cs file slightly to this:

ModuleDatabase.scanModules( "./modules" );

So it would be relative to the file instead of the app. The rest of the paths in the modules are relative to the executing file so they should be fine.

Do you think that's a good way to solve it?

chaigler commented 8 years ago

That's clever!

Apparently there's a way of including a "default" .user file with each project but that would mean making git aware of .user files which isn't ideal.

greenfire27 commented 8 years ago

Alright. Then we'll move forward with my plan. I'll make a pull request. The best part is that if you already changed your project settings like you did, this won't break it. You'll just avoid calling the extra main.cs.

greenfire27 commented 8 years ago

This has been resolved