WSL 上 Visual Studio 代码的导出扩展列表

Export extension list for Visual Studio Code on WSL

我在 Windows 10 上激活了 WSL2(Windows 子系统 für Linux)(Alpine 和 Ubuntu 作为发行版),我在 VScode。在我的“正常”VScode 上,我可以 code --list-extensions 获得我所有的扩展。

如何在 WSL 远程终端(zsh,bash)上执行此操作?

VS Code 通过安装在 Linux 机器上的服务器组件与 WSL2 通信,显然到目前为止不支持 --list-extensions 标志。

相同命令 code --list-extensions 输入 Windows 和 WSL 显示的相同命令的以下输出差异

在 WSL 上

code 1.49.0

Usage: code [options][paths...]

To read from stdin, append '-' (e.g. 'ps aux | grep code | code -')

Options
  -d --diff <file> <file>           Compare two files with each other.
  -a --add <folder>                 Add folder(s) to the last active window.
  -g --goto <file:line[:character]> Open a file at the path on the specified line and 
character position.
  -n --new-window                   Force to open a new window.
  -r --reuse-window                 Force to open a file or folder in an already 
opened window.
  --folder-uri <uri>                Opens a window with given folder uri(s)
  --file-uri <uri>                  Opens a window with given file uri(s)
  -w --wait                         Wait for the files to be closed before returning.
  --locale <locale>                 The locale to use (e.g. en-US or zh-TW).
  -h --help                         Print usage.

Extensions Management
  --enable-proposed-api <extension-id> Enables proposed API features for extensions. 
Can receive one or more extension
                                       IDs to enable individually.

Troubleshooting
  -v --version                       Print version.
  --verbose                          Print verbose output (implies --wait).
  --log <level>                      Log level to use. Default is 'info'. Allowed 
values are 'critical', 'error',
                                     'warn', 'info', 'debug', 'trace', 'off'.
  -s --status                        Print process usage and diagnostics information.
  --prof-startup                     Run CPU profiler during startup
  --disable-extensions               Disable all installed extensions.
  --disable-extension <extension-id> Disable an extension.
  --sync <on> <off>                  Turn sync on or off
  --inspect-extensions <port>        Allow debugging and profiling of extensions. 
Check the developer tools for the
                                     connection URI.
  --inspect-brk-extensions <port>    Allow debugging and profiling of extensions with 
the extension host being paused
                                     after start. Check the developer tools for the 
connection URI.
  --disable-gpu                      Disable GPU hardware acceleration.
  --max-memory                       Max memory size for a window (in Mbytes).

在 Windows

Visual Studio Code 1.49.0

Usage: code.exe [options][paths...]

To read output from another program, append '-' (e.g. 'echo Hello World | code.exe -')

Options
  -d --diff <file> <file>           Compare two files with each other.
  -a --add <folder>                 Add folder(s) to the last active window.
  -g --goto <file:line[:character]> Open a file at the path on the specified
                                    line and character position.
  -n --new-window                   Force to open a new window.
  -r --reuse-window                 Force to open a file or folder in an
                                    already opened window.
  --folder-uri <uri>                Opens a window with given folder uri(s)
  --file-uri <uri>                  Opens a window with given file uri(s)
  -w --wait                         Wait for the files to be closed before
                                    returning.
  --locale <locale>                 The locale to use (e.g. en-US or zh-TW).
  --user-data-dir <dir>             Specifies the directory that user data is
                                    kept in. Can be used to open multiple
                                    distinct instances of Code.
  -h --help                         Print usage.

Extensions Management
  --extensions-dir <dir>
      Set the root path for extensions.
  --list-extensions
      List the installed extensions.
  --show-versions
      Show versions of installed extensions, when using --list-extension.
  --category
      Filters installed extensions by provided category, when using --list-extension.
  --install-extension <extension-id[@version] | path-to-vsix>
      Installs or updates the extension. Use `--force` argument to avoid prompts. The identifier of an extension is always `${publisher}.${name}`. To install a specific version provide `@${version}`. For example: 'vscode.csharp@1.2.3'.
  --uninstall-extension <extension-id>
      Uninstalls an extension.
  --enable-proposed-api <extension-id>
      Enables proposed API features for extensions. Can receive one or more extension IDs to enable individually.

Troubleshooting
  -v --version                       Print version.
  --verbose                          Print verbose output (implies --wait).
  --log <level>                      Log level to use. Default is 'info'.
                                     Allowed values are 'critical', 'error',
                                     'warn', 'info', 'debug', 'trace', 'off'.
  -s --status                        Print process usage and diagnostics
                                     information.
  --prof-startup                     Run CPU profiler during startup
  --disable-extensions               Disable all installed extensions.
  --disable-extension <extension-id> Disable an extension.
  --sync <on> <off>                  Turn sync on or off
  --inspect-extensions <port>        Allow debugging and profiling of
                                     extensions. Check the developer tools for
                                     the connection URI.
  --inspect-brk-extensions <port>    Allow debugging and profiling of
                                     extensions with the extension host being
                                     paused after start. Check the developer
                                     tools for the connection URI.
  --disable-gpu                      Disable GPU hardware acceleration.
  --max-memory                       Max memory size for a window (in Mbytes).
  --telemetry                        Shows all telemetry events which VS code
                                     collects.

注意输出的 Extension Management 部分

正如@dopewind 所指出的,WSL 中的 vscode 不支持 --list-extensions 标志。
您可以通过检查 vscode UI html:
来获取列表 在 WSL 中打开 vscode,转到“帮助”>“切换开发人员工具”。
Select 扩展,并按已安装进行过滤。
Select Developer Tools 中的 Extensions div,然后转到 Console 打印列表:
[=10=].innerText

你试过吗extensions.json?

当我在 WSL 和 Windows 之间切换以管理平台之间的扩展时,我使用 extensions.json 方法。 更多详情,Click Here

您应该在 .vscode 文件夹中创建 extensions.json。

我不确定我的解决方案是否对问题有所帮助,但它提供了在整个团队中轻松管理扩展的不同视角。