如何调试 Visual Studio 扩展 [英] How to debug Visual Studio extensions
问题描述
我正在为 Visual Studio 2010 编写 VSIX 扩展,但不知道如何调试它.
I'm just writing a VSIX extension for Visual Studio 2010 and can't figure out how to debug it.
一种明显的方法是输出消息.扩展模板使用 Trace.WriteLine()
.但是在哪里可以找到它的输出?
One obvious method is to output messages. Extension template uses Trace.WriteLine()
. But where to find it's output?
推荐答案
Visual Studio 扩展可以像任何其他应用程序一样进行调试.您只需要设置调试体验即可使用加载的扩展启动 devenv.试试下面的
Visual Studio Extensions can be debugged like any other application. You just need to setup the debug experience to launch devenv with the loaded extension. Try the following
- 右键单击项目并选择属性
- 转到调试选项卡
点击启动外部程序
的单选按钮.将其指向 devenv.exe 二进制文件.在我的机器上它位于
Click on the radio button for Start External Program
. Point it to the devenv.exe binary. On my machine it's located at
C:Program Files (x86)Microsoft Visual Studio 10.0Common7IDEdevenv.exe
C:Program Files (x86)Microsoft Visual Studio 10.0Common7IDEdevenv.exe
在非 x64 机器上,您可以删除(x86)"部分.
On a non x64 machine though you can remove the " (x86)" portion.
然后将命令行参数设置为 /rootsuffix Exp
.这告诉 Visual Studio 使用实验配置单元而不是正常配置配置单元.默认情况下,构建后的 VSIX 扩展将在实验配置单元中注册自己.
Then set the command line arguments to /rootsuffix Exp
. This tells Visual Studio to use the experimental hive instead of the normal configuration hive. By default VSIX extensions when built will register themselves in the experimental hive.
现在您可以按 F5,它将启动 Visual Studio,并将您的 VSIX 作为可用扩展.
Now you can F5 and it will start Visual Studio with your VSIX as an available extension.
这篇关于如何调试 Visual Studio 扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!