如何调试 Visual Studio 代码扩展?
How to debug Visual Studio Code extensions?
排查和调试 Visual Studio 代码的最佳方法是什么?
我在编辑 Visual Studio 代码时遇到了一些 snippet/suggestion 扩展冲突,想找出根本原因。
P.S。如果有任何解决扩展之间冲突的经验,我将不胜感激。如果您以前遇到过此问题,请随意插话(内置建议会在几秒钟后完全覆盖扩展建议)
摘自https://code.visualstudio.com/docs/extensions/developing-extensions:
Running and debugging your extension
You can easily run your extension under the debugger by pressing F5.
This opens a new VS Code window with your extension loaded. Output
from your extension shows up in the Debug Console
. You can set break
points, step through your code, and inspect variables either in the
Debug
view or the Debug Console
.
要调试已安装的 Visual Studio 代码扩展,首先 导航到已安装扩展的项目文件夹。
%USERPROFILE%\.vscode\extension${PublisherName}.${ExtensionName}-${VersionNumber}\
此文件夹包含在您的用户配置文件或根文件夹中。根据您安装的 Visual Studio 代码的版本,它也可能被称为 .vscode-insiders
。
此项目文件夹应该已经设置了调试器,您只需在项目源文件中按 F5 即可打开 [Extension Development Host]
如最初假设的那样。
有关详细信息,如果您需要微调这些设置,您可以查看 <projectroot>/.vscode/launch.json
以找到详细说明 [Extension Development Host]
使用的启动配置。
示例取自自动生成的扩展调试器设置 launch.json
:
// A launch configuration that compiles the extension and then opens it inside a new window
{
"version": "0.1.0",
"configurations": [{
"name": "Launch Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}"]
}]
}
从那里开始,添加断点只是一个简单的 (~) 问题 and/or 控制台日志来找出与扩展相关的问题的原因。
~ 编辑:我现在有足够的代表来嵌入图像
有关 Visual Studio 代码扩展的一般开发的更多信息,请参阅此处的官方文档:
https://code.visualstudio.com/docs/extensions/developing-extensions#_creating-your-own-extension
要查看您正常安装的其他人的扩展程序的错误:
- 在菜单中,select
View
> Output
- Select 输出右上角小下拉列表中的扩展 window
排查和调试 Visual Studio 代码的最佳方法是什么?
我在编辑 Visual Studio 代码时遇到了一些 snippet/suggestion 扩展冲突,想找出根本原因。
P.S。如果有任何解决扩展之间冲突的经验,我将不胜感激。如果您以前遇到过此问题,请随意插话(内置建议会在几秒钟后完全覆盖扩展建议)
摘自https://code.visualstudio.com/docs/extensions/developing-extensions:
Running and debugging your extension
You can easily run your extension under the debugger by pressing F5. This opens a new VS Code window with your extension loaded. Output from your extension shows up in the
Debug Console
. You can set break points, step through your code, and inspect variables either in theDebug
view or theDebug Console
.
要调试已安装的 Visual Studio 代码扩展,首先 导航到已安装扩展的项目文件夹。
%USERPROFILE%\.vscode\extension${PublisherName}.${ExtensionName}-${VersionNumber}\
此文件夹包含在您的用户配置文件或根文件夹中。根据您安装的 Visual Studio 代码的版本,它也可能被称为 .vscode-insiders
。
此项目文件夹应该已经设置了调试器,您只需在项目源文件中按 F5 即可打开 [Extension Development Host]
如最初假设的那样。
有关详细信息,如果您需要微调这些设置,您可以查看 <projectroot>/.vscode/launch.json
以找到详细说明 [Extension Development Host]
使用的启动配置。
示例取自自动生成的扩展调试器设置 launch.json
:
// A launch configuration that compiles the extension and then opens it inside a new window
{
"version": "0.1.0",
"configurations": [{
"name": "Launch Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}"]
}]
}
从那里开始,添加断点只是一个简单的 (~) 问题 and/or 控制台日志来找出与扩展相关的问题的原因。
有关 Visual Studio 代码扩展的一般开发的更多信息,请参阅此处的官方文档: https://code.visualstudio.com/docs/extensions/developing-extensions#_creating-your-own-extension
要查看您正常安装的其他人的扩展程序的错误:
- 在菜单中,select
View
>Output
- Select 输出右上角小下拉列表中的扩展 window