ELLIOTTCABLE
ELLIOTTCABLE

Reputation: 18108

How do I disable all extraneous extensions in the VS Code "Extension Development Host" without it overwriting my normal user-config?

I'm trying to debug / develop on a VSCode extension. To do so, I need to disable all of my (many) other extensions in the debugging "Extension Development Host."

Doing so, however, saves to my user-preferences, which then causes … all of my other VScode instances … to stop having any extensions.

How can I disable my other, everyday extensions in the "Extension Development Host" without screwing up my normal user-config? Is there a way to convince the EDH to use a different settings-file or configuration-path or something, repeatedly and reliably?

Upvotes: 10

Views: 11014

Answers (2)

Mark
Mark

Reputation: 182571

See Support extension debugging in a clean environment. And v1.72 Release Notes Extension debugging in a clean environment

You must have this setting enabled for the following technique to work in Stable 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).

  • The above requirement has been remeoved in the Insiders Build

So, for example, I have the following args in a launch configuration:

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

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

      "--extensionDevelopmentPath=${workspaceFolder}"
   ]

and it works well. The ExtensionHost has no extensions installed, but my other vscode windows are unaffected.

Below from v1.72 Release Notes Extension debugging in a clean environment

Please note: when debugging an extension in a remote location (via the "Remote Development" extensions "Containers", "SSL", or "WSL"), using the --profile-temp flag will result in this status message:

temporary profile in a remote situation error message

This is expected because the temporary profile does not include any extensions, which means that the "Remote Development" extensions are missing too. For remote scenarios it is recommended to create an empty named profile, add the "Remote Development" extensions to it, and then use the --profile=.... command line option.

Upvotes: 3

nclskfm
nclskfm

Reputation: 212

You can disable all extensions with the --disable-extensions flag. Just reconfigure your .vscode/launch.json (see args array):

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Run Extension",
            "type": "extensionHost",
            "request": "launch",
            "args": [
                "--extensionDevelopmentPath=${workspaceFolder}",
                "--disable-extensions"
            ],
            "outFiles": [
                "${workspaceFolder}/out/**/*.js"
            ],
            "preLaunchTask": "${defaultBuildTask}"
        },
        ...

Upvotes: 8

Related Questions