How to Debug a Visual Studio Extension

Posted on
Visual Studio Debugging

Here are a few tips for debugging Visual Studio Extensions.

Visual Studio 2008/2010

If you need to debug your Visual Studio extension, you may find that Visual Studio itself locks it. This is a real drag - to resolve this issue, add the following as a pre-build step:

if exist "$(TargetPath).locked" del "$(TargetPath).locked"
if not exist "$(TargetPath).locked" if exist "$(TargetPath)" 
move "$(TargetPath)" "$(TargetPath).locked"

This will ensure the locked file is moved out of the way first - very useful!

Visual Studio 2010

Every time I do a clean checkout of one of my projects, it seems to lose the ability to be run in the Experimental mode of visual studio. Here's a quick tip - if you lose the ability to debug your visual studio extension, make sure you have the 'Debug' tab of your project set up as below:

Specifically with the external program set as visual studio and the command line arguments as /rootsuffix exp. This will run your extension in the Experimental Instance of Visual Studio.