views:

38

answers:

1

I have an application that runs hosted under the "w3wp.exe" process.

While debugging, I often find myself following these steps:

1 - Make some change

2 - Build the project

3 - Attach to "w3wp.exe" using the "attach to process" dialog under the Tools menu.

4 - Perform some action in the application to make my code execute, so I can step through it in the debugger

I'd like to automate step 3 in the post-build script, so that the IDE automatically attaches to the process after the build is completed. Note that I already launch the application as a part of the post-build process, so I can count on the process existing at this point.

Does anyone know a way to automate the "attach to process" command? Something from the command line would be especially nice, but a macro would do, too.

I'm using Visual Studio 2008 under Windows 7, 64 bit.

Edit @InSane basically gave me the right answer, but it does not work because I need to debug managed code, rather than native code. It seems that vsjitdebugger defaults to Native code, and thus my breakpoint is not hit. From inside the IDE, I can specify "managed code" and the debugger attaches as expected. So is there any way to point vsjitdebugger to managed code?

+2  A: 

You can try the following command from the Windows command line.

If it works as you expect, you can put it as part of your postbuild steps.

ProcessID is the ID of the process you have launched that you want to attach to.

vsjitdebugger.exe -p ProcessId 

Other options for using this from the command line include :- alt text

InSane
Upvote for a great suggestion, but it doesn't quite work. If I use that command, it asks me if I want to use the current debugger, or start up a new one. I choose the current one, and it thinks pretty hard for a bit, but then any breakpoint I have set comes up with "The breakpoint will not currently be hit. No symbols have been loaded for this document." If I manually choose the same process from within the IDE, then the breakpoint sets up correctly. Any ideas?
JosephStyons
@JosephStyons - Am not sure if this will work but is it possible for you have to specify the debug symbol folder beforehand in VS --> Options --> Debugging --> Symbols --> Symbol File locations --> <your folder where the .pdb files are located>. That may help the debugger know where to look for the symbols...
InSane