visual-studio-code - 如何禁用 VS 代码 "Extension Development Host"中的所有无关扩展而不覆盖我的正常用户配置?

标签 visual-studio-code vscode-extensions configuration-files

我正在尝试调试/开发 VSCode 扩展。为此,我需要在调试“扩展开发主机”中禁用所有(许多)其他扩展。

然而,这样做会保存到我的用户首选项,然后导致……我所有其他 VScode 实例……停止任何扩展。

如何在“扩展开发主机”中禁用我的其他日常扩展而不破坏我的正常用户配置?有没有办法说服 EDH 反复可靠地使用不同的设置文件或配置路径或其他东西?

最佳答案

参见 Support extension debugging in a clean environment .和 v1.72 Release Notes Extension debugging in a clean environment

您必须启用此设置才能在稳定版 v1.71+ 中使用以下技术:

Workbench > Experimental > Settings Profile: Enabled

With the "settings profile" feature and the new command line support for profiles it is now possible to specify profiles in the extension's debug configuration.

There are basically two possible approaches:

"debugging in a clean environment" by using an unnamed "empty" profile that gets automatically deleted when debugging has stopped.

"debugging in a controlled environment" by using a named profile that has been created specifically for extension debugging and contains specific settings and extensions.

This debug configuration shows how to "debug in a clean environment":

{
    "name": "Extension",
    "type": "extensionHost",
    "request": "launch",
    "args": [
        "--profile-temp",
        "--extensionDevelopmentPath=${workspaceFolder}",
        "${workspaceFolder}/sampleWorkspace"
    ],
    "outFiles": [
        "${workspaceFolder}/dist/**/*.js"
    ],
    "preLaunchTask": "npm: watch"
}

Please note: the configuration from above passes a workspace folder ${workspaceFolder}/sampleWorkspace which is currently mandatory for the --profile-temp option. If the workspace folder argument is missing, the --profile-temp option is silently ignored. We will try to remove this requirement soon (see issue #159577).

  • 上述要求已在 Insiders Build 中删除

因此,例如,我在启动配置中有以下 args:

    "args": [
      "--profile-temp",

      // some folder is necessary for now in Stable (but not Insiders), using the `${workspaceFolder}` variable
      "${workspaceFolder}/../OneDrive/Test Bed",

      "--extensionDevelopmentPath=${workspaceFolder}"
   ]

而且效果很好。 ExtensionHost 没有安装任何扩展,但我的其他 vscode 窗口不受影响。

下面来自 v1.72 Release Notes Extension debugging in a clean environment

请注意:在远程位置调试扩展时(通过“远程开发”扩展“Containers”、“SSL”或“WSL”),使用--profile-temp标志将导致此状态消息:

temporary profile in a remote situation error message

这是预料之中的,因为临时配置文件不包含任何扩展,这意味着“远程开发”扩展也丢失了。对于远程方案,建议创建一个空的命名配置文件,向其添加“远程开发”扩展,然后使用 --profile=.... 命令行选项。

关于visual-studio-code - 如何禁用 VS 代码 "Extension Development Host"中的所有无关扩展而不覆盖我的正常用户配置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71572862/

相关文章:

visual-studio-code - 如何使用 Azure DevOps 在 Visual Studio Code 中管理完整的 Pull Request 流程

.net - 无法保存 applicationHost.config 文件

windows - 如何在 Windows 上调试 Rust 单元测试?

python-3.x - 是否有用于变量名称的 Python (3) lint,例如 'len'(内置函数/保留字等)

node.js - VS Code 调试在 createScript 函数中停止在 vm.js

visual-studio-code - 定义 "always wins"的 VSCode Scheme Syntax 规则

git - VSCode,如何比较分支和目录并轻松浏览更改?

html - VSCode 扩展 webview 外部 html 和 css

c# - .NET-Assemblies 的默认 (assembly).dll.config 文件有什么用?

c# - 有没有办法加密 Windows 窗体应用程序的配置文件?