Jakew
Consulting, hacking, and motorcycles

Visual Studio automation – make debug easier

Wednesday, 8 October 2008 12:31 by jakew

My current project is a bit of a pain.  I'm having to dance between 2 to 4 instance of Visual Studio while I'm testing and debugging!  I can merge three of the solutions in to one solution file to reduce it, but I don't really want to do that for a number of reasons I'm not going to go in to.  Suffice it to say I'm a bit stuck with the current situation.

However, with a bit of macro hacking I'm able to make my life a tad easier.  I can build the project I'm working on.  Launch its host, launch the client and then attach the debugger to both so that I can take control.

I had to search around to get the details, but nobody really had the whole thing put together.  Koen's blog has part of what you need - he shows how to attach the VS debugger to an already running process.  What nobody really mentions is how to go about getting the process running in the first place.

After searching the docs it seems VS doesn't really provide a way to launch a project's executable.  You have to do it yourself.  VB and C# project objects have properties that will tell you the output directory and the output assembly.  The output path is relative so you'll have to turn it in to a full path by getting the project's path and then navigating from there.

Once you have the full path to the executable just use System.Diagnstics.Process.Start to launch the program.  Once the program has been started attach the debugger.

In my case I have to start my service hosts (there are 3 of them) then start the client and then attach the debugger.

The Macro isn't exactly clean yet.  Once I have something cleaner I'll share, but the details above give you everything you need to know.

Resources:

http://weblogs.asp.net/koenv/archive/2008/02/14/quick-attach-and-detach-debugger.aspx

Categories:  
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed