Reputation: 10319
How to install Visual Studio Code Extensions from Command Prompt while Code Instance is open. I want to install extension from Visual Studio Code gallery.
Following is the extension data i want to install.
My Visual Studio Code Instance is open. What i want to do is to install the following extension from command prompt.
Upvotes: 115
Views: 117008
Reputation: 10319
To make it easier to automate and configure VS Code, it is possible to list, install, and uninstall extensions from the command line. When identifying an extension, provide the full name of the form publisher.extension, for example donjayamanne.python.
code --list-extensions
code --install-extension ms-vscode.cpptools
code --uninstall-extension ms-vscode.csharp
You can also include extensions from local .vsix files like this:
code --install-extension <extension-vsix-path>
Usage:
code --install-extension hello-world-extension.vsix
Upvotes: 183
Reputation: 39
#!/bin/bash
# by Cypher
# grab your extensions with:
# codium (or code) --list-extensions --show-versions > codeium.ext
# tweak your extension list to be like the one below
# you can create a $var for "codium --force --install-extension", if you wish...
# https://codeium.com/
# make a bashscript (in GNU/Linux) and easily install them:
# So that the bashscript can be portable for reproducing your config in anoter machine(s)
# save this as, say, "codeiumExtensions.sh"
# chmod +x codeiumExtensions.sh
# then, run it:
# as normal user: ./codeiumExtensions.sh
# codium --help
# --force installs the latest version
codium --force --install-extension [email protected]
codium --force --install-extension [email protected]
codium --force --install-extension [email protected]
codium --force --install-extension [email protected]
codium --force --install-extension [email protected]
codium --force --install-extension [email protected]
codium --force --install-extension [email protected]
codium --force --install-extension [email protected]
codium --force --install-extension [email protected]
codium --force --install-extension [email protected]
codium --force --install-extension [email protected]
codium --force --install-extension [email protected]
codium --force --install-extension [email protected]
codium --force --install-extension [email protected]
codium --force --install-extension [email protected]
codium --force --install-extension [email protected]
codium --force --install-extension [email protected]
codium --force --install-extension [email protected]
codium --force --install-extension [email protected]
codium --force --install-extension [email protected]
codium --force --install-extension [email protected]
codium --force --install-extension [email protected]
Upvotes: 0
Reputation: 4391
To install multiple extensions at the same time, use this format:
code --install-extension dakshmiglani.hex-to-rgba --install-extension dudemelo.php
Upvotes: 2
Reputation: 51
In a Microsoft tutorial "[https://learn.microsoft.com/de-de/azure/azure-signalr/signalr-tutorial-authenticate-azure-functions][1]" they show the following:
func extensions install -p Microsoft.Azure.WebJobs.Extensions.SignalRService -v 1.0.0
but it don't works. So I try a part from here:
code --install-extension Microsoft.Azure.WebJobs.Extensions.SignalRService -v 1.0.0
an got the answer:
1.56.2
054a9295330880ed74ceaedda236253b4f39a335
x64
I hope it will work now...
Upvotes: 3
Reputation: 20464
The PowerShell script provided by @derekbaker783 didn't worked for me, it throws an exception related that "Code" is not a cmdlet, so I'll share an alternative that worked for me:
$vsCodeExec = ($Env:PROGRAMFILES) + "\Visual Studio Code\Bin\code.cmd"
$extensions = @(
"ms-vscode.cpptools", # C/C++ Language Support
"ms-dotnettools.csharp", # C# Language Support
"dbankier.vscode-instant-markdown", # Markdown Language Support
"ms-vscode.powershell", # PowerShell Language Support
"ms-python.python", # Python Language Support
"rebornix.ruby", # Ruby Language Support
"spences10.vba", # VBA Language Support
"luggage66.vbscript", # VBScript Language Support
"gordonwalkedby.vbnet", # VB.NET Language Support
"dotjoshjohnson.xml", # XML Language Support
"abusaidm.html-snippets", # HTML Snippets
"ecmel.vscode-html-css", # CSS Intellisense for HTML
"formulahendry.code-runner", # Code Runner
"ms-vscode-remote.remote-wsl", # VSCode Remote - WSL
"vscode-icons-team.vscode-icons", # Icons for VSCode
"ms-vscode.vs-keybindings", # Visual Studio Keymap for VSCode
"abhiagr.livs" # Open/Launch in Visual Studio
) | SORT
$extensions | ForEach-Object {
try {
Invoke-Expression "& '$vsCodeExec' --install-extension $_ --force"
Write-Host # New-Line
} catch {
$_
Exit(1)
}
}
Exit(0)
Upvotes: 5
Reputation: 9581
First, find the fully qualified extension name. To do this, you can right-click a given extension, and select 'Copy Extension Id' (while in the extensions pane).
Since the other answers already illustrate .BAT/.CMD syntax, here's an example of installing extensions using a Powershell script (which can of course be executed from CMD).
# A system-wide install of VSCode might be in: "C:\Program Files\Microsoft VS Code\bin\code"
param(
[string] $pathToVsCodeExe = ($Env:USERPROFILE + '\AppData\Local\Programs\Microsoft VS Code'),
[string[]] $extensions = @("editorconfig.editorconfig", "dbaeumer.vscode-eslint")
)
try {
$originalLocation = Get-Location
Set-Location $pathToVsCodeExe
$extensions | ForEach-Object {
Invoke-Expression -Command "Code --install-extension $_ --force"
}
}
catch {
$_
}
finally {
Set-Location $originalLocation
}
Upvotes: 2
Reputation: 2519
I believe what you want is to install an extension as .vsix file. Documentation here. Copied for reference.
You can manually install an VS Code extension packaged in a .vsix file. Simply install using the VS Code command line providing the path to the .vsix file.
code --install-extension myExtensionFolder\myExtension.vsix
The extension will be installed under your user .vscode/extensions folder. You may provide multiple .vsix files on the command line to install multiple extensions at once.
Upvotes: 11
Reputation: 161
To add to Shan Khan's answer above, if you want to install extensions in a .bat file, you have to use the call
keyword, otherwise your script exits after the extension installation completes. Also, if code.exe is not already in the path and you are calling using a full path, make sure you're pointing at the /bin
directory:
echo.
echo.
echo Installing VS Code Extensions...
call "C:\Program Files\Microsoft VS Code\bin\code" --install-extension ritwickdey.liveserver
call "C:\Program Files\Microsoft VS Code\bin\code" --install-extension ritwickdey.live-sass
call "C:\Program Files\Microsoft VS Code\bin\code" --install-extension ms-vscode.csharp
call "C:\Program Files\Microsoft VS Code\bin\code" --install-extension PKief.material-icon-theme
echo Done.
echo.
echo.
Upvotes: 15
Reputation: 244757
According to the documentation, you can use --install-extension
for that. For example:
code --install-extension ms-vscode.csharp
Upvotes: 21