How can you export VS Code extension list

2019-01-20 21:22发布

问题:

I need to send all my installed extensions to my colleagues, how can I export them?

Extension manager seems to do nothing... It won't install any extension.

回答1:

Manual - By script

In machine A,

code --list-extensions | xargs -L 1 echo code --install-extension

copy and paste the echo output to machine B

sample output

code --install-extension Angular.ng-template
code --install-extension DSKWRK.vscode-generate-getter-setter
code --install-extension EditorConfig.EditorConfig
code --install-extension HookyQR.beautify

Please make sure you have code command line installed. For more information, please visit https://code.visualstudio.com/docs/editor/command-line

Automatic : - Using Extension

If you are looking for the extension from which you can export the list, update and share with coworkers.

These is an extension called Settings Sync that does all those things in just command.



回答2:

I've need to do this myself a few times - especially when installing on another machine.

https://code.visualstudio.com/docs/editor/extension-gallery#_common-questions will give you the location of your folder

VS Code looks for extensions under your extensions folder .vscode/extensions. Depending on your platform it is located:

Windows %USERPROFILE%\.vscode\extensions
Mac ~/.vscode/extensions
Linux ~/.vscode/extensions

That should show you a list of the extensions

I've also had success using Visual Studio Code Settings Sync Extension to sync settings to GitHub gist

EDIT: In the lastest release of VSCode (May 2016) it is now possible to list the installed extension in the command line

code --list-extensions


回答3:

I have developed an extension which will sync your all Visual Studio Code Settings Across multiple instances.

Key Features

  1. Use your github account token.
  2. Easy to Upload and Download on one click.
  3. Saves all settings and snippets files.
  4. Upload Key : Shift + Alt + u
  5. Download Key : Shift + Alt + d
  6. Type Sync In Order to View all sync options

It Sync

  1. Settings File
  2. Keybinding File
  3. Launch File
  4. Snippets Folder
  5. VSCode Extensions

Detail Documentation Source

VSCode Sync ReadMe

Download here : VS Code Settings Sync



回答4:

I used the following command to copy my extensions from vscode to vscode insiders:

code --list-extensions | xargs -L 1 code-insiders --install-extension

The argument -L 1 allows us to execute the command code-insiders --install-extension once for each input line generated by code --list-extensions



回答5:

Generate windows command for install extensions.

for /F "tokens=*" %i in ('code --list-extensions')
   do @echo call code --install-extension %i >> install.cmd


回答6:

Windows (Powershell) version of @Benny's answer

Machine A:

In VSCode Powershell terminal :

code --list-extensions > extensions.list

Machine B:

  1. Copy extension.list to the machine B

  2. In VSCode Powershell terminal :

cat extensions.list |% { code --install-extension $_}



回答7:

Open VScode console and write:

code --list-extensions (or code-insiders --list-extensions if vscode insider is installed)

Then share with colleagues the commande line:

code --install-extension {ext1} --install-extension {ext2} --install-extension {extN} replacing {ext1}, {ext2}, ... , {extN} with the extention tou listed

For vscode insider: code-insiders --install-extension {ext1} ...

If they copy/paste it in vscode commande line terminal, they'll install the shared extensions

More information on command-line-extension-management



回答8:

There is an Extension Manager extension, that may help. It seems to allow to install a set of extensions specified in the settings.json.



回答9:

I opened the VSCode extensions folder and executed

find * -maxdepth 2 -name "package.json" | xargs grep "name"

That gives you a list from which you can extract the extension names.



回答10:

Benny's answer on Windows with Linux subsystem:

C:\> code --list-extensions | wsl xargs -L 1 echo code --install-extension


回答11:

https://code.visualstudio.com/docs/editor/extension-gallery#_workspace-recommended-extensions

better way to share extension list is to create workspace-based extension set for your collegues

after generating list of extension via code --list-extensions | xargs -L 1 echo code --install-extension (check your $PATH contains vscode entry c:\Program Files\Microsoft VS Code\bin\ before running code commands)

run Extensions: Configure Recommended Extensions (Workspace Folder) VsCode command (Ctrl+Shift+P) and put extensions into generated .vscode/extensions.json:

{
    "recommendations": [
        "eg2.tslint",
        "dbaeumer.vscode-eslint",
        "msjsdiag.debugger-for-chrome"
    ]
}


回答12:

If you intend to share workspace extensions config across a team, you should look into the Recommended Extensions feature of VSCode.

To generate this file open the command pallet > Configure Recommended Extensions (Workspace Folder). From there if you wanted to get all of your current extensions and put them in here you could use the --list-extensions stuff mentioned in other answers, but add some awk to make it paste-able into a json array (you can get more or less advanced with this as you please, this is just a quick example):

code --list-extensions | awk '{ print "\""$0"\"\,"}'

The advantage of this method is that your team-wide workspace config can be checked into source control. With this file present in a project, when the project is opened VSCode will notify the user there are recommended extensions to install (if they don't already have them) and can install them all with a single button press.



回答13:

For those that are wondering how to copy your extensions from vs code to vs code insiders, use this modification of Benny's answer:

code --list-extensions | xargs -L 1 echo code-insiders --install-extension



回答14:

For Linux/Mac only, export installed Visual Studio Code extensions in a Form of installation Script. It's Zsh script, but may run in bash as well.

https://gist.github.com/jvlad/6c92178bbfd1906b7d83c69780ee4630