I have installed Visual Studio Code on a machine that is not, and cannot be, connected to the Internet. According to the documentation, I can install an extension from the c
All these suggestions are great, but kind of painful to follow because executing the code to construct the URL or constructing that crazy URL by hand is kind of annoying...
So, I threw together a quick web app to make things easier. Just paste the URL of the extension you want and out comes out the download of your extension already properly named: publisher-extension-version.vsix.
Hope someone finds it helpful: http://vscode-offline.herokuapp.com/
You can now download the extension directly from the marketplace.
As of Visual Studio Code 1.7.1 dragging or opening the extension does not work any more. In order to install it manually you need to:
According to the documentation it is possible to download an extension directly:
An extension's direct download URL is in the form:
https://${publisher}.gallery.vsassets.io/_apis/public/gallery/publisher/${publisher}/extension/${extension name}/${version}/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage
This means that in order to download the extension you need to know
You can find all this information in the URL.
Here's an example for downloading an installing the C# v1.3.0 extension:
You can find the publisher and the extension names on the extension's homepage inside its URL:
https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp
Here the publisher is ms-vscode
and the extension name is csharp
.
The version can be found on the right side in the More Info area.
To download it you need to create a link from the template above:
https://ms-vscode.gallery.vsassets.io/_apis/public/gallery/publisher/ms-vscode/extension/csharp/1.3.0/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage
All packages will have the same name Microsoft.VisualStudio.Services.VSIXPackage, so you'll need to rename it after downloading if you want to know what package it was later.
In order to install the extension
*.vsix
extension.vsix
fileExtension was successfully installed. Restart to enable it.
If you have a specific (legacy) version of VSCode on your offline instance, pulling the latest extensions might not properly integrate.
To make sure that VSCode and the extensions work together, they must all be installed together on the online machine. This resolves any dependencies (with specific versions), and ensures the exact configuration of the offline instance.
Install the VSCode version, turn off updating, and install the extensions. Copy the extensions from the installed location and place them on the target machine.
Install the exact version of VSCode on online machine. Then turn off updates by going to File -> Preferences -> Settings
. In the Settings
window, under User Settings -> Application
, go to Update
section, and change the parameter for Channel
to none
. This prevents VSCode from reaching out to the internet and auto-updating your versions to the latest.
Then go to the VSCode extensions section and install all of your desired extensions. Copy the installed extensions from their install location (with windows its C:\Users\<username>\.vscode\extensions
) to the same location on the target machine.
Works perfectly.
A small powershell to get needed information for also visual studio extension :
function Get-VSMarketPlaceExtension {
[CmdLetBinding()]
Param(
[Parameter(ValueFromPipeline = $true,Mandatory = $true)]
[string[]]
$extensionName
)
begin {
$body=@{
filters = ,@{
criteria =,@{
filterType=7
value = $null
}
}
flags = 1712
}
}
process {
foreach($Extension in $extensionName) {
$response = try {
$body.filters[0].criteria[0].value = $Extension
$Query = $body|ConvertTo-JSON -Depth 4
(Invoke-WebRequest -Uri "https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery?api-version=6.0-preview" -ErrorAction Stop -Body $Query -Method Post -ContentType "application/json")
} catch [System.Net.WebException] {
Write-Verbose "An exception was caught: $($_.Exception.Message)"
$_.Exception.Response
}
$statusCodeInt = [int]$response.StatusCode
if ($statusCodeInt -ge 400) {
Write-Warning "Erreur sur l'appel d'API : $($response.StatusDescription)"
return
}
$ObjResults = ($response.Content | ConvertFrom-Json).results
If ($ObjResults.resultMetadata.metadataItems.count -ne 1) {
Write-Warning "l'extension '$Extension' n'a pas été trouvée."
return
}
$Extension = $ObjResults.extensions
$obj2Download = ($Extension.versions[0].properties | Where-Object key -eq 'Microsoft.VisualStudio.Services.Payload.FileName').value
[PSCustomObject]@{
displayName = $Extension.displayName
extensionId = $Extension.extensionId
deploymentType = ($obj2Download -split '\.')[-1]
version = [version]$Extension.versions[0].version
LastUpdate = [datetime]$Extension.versions[0].lastUpdated
IsValidated = ($Extension.versions[0].flags -eq "validated")
extensionName = $Extension.extensionName
publisher = $Extension.publisher.publisherName
SourceURL = $Extension.versions[0].assetUri +"/" + $obj2Download
FileName = $obj2Download
}
}
}
}
This use marketplace API to get extension information. Exemple of usage and results :
>Get-VSMarketPlaceExtension "ProBITools.MicrosoftReportProjectsforVisualStudio"
displayName : Microsoft Reporting Services Projects
extensionId : 85e42f76-6afa-4a68-afb5-033d1fe08d7b
deploymentType : vsix
version : 2.6.7
LastUpdate : 13/05/2020 22:23:45
IsValidated : True
extensionName : MicrosoftReportProjectsforVisualStudio
publisher : ProBITools
SourceURL : https://probitools.gallery.vsassets.io/_apis/public/gallery/publisher/ProBITools/extension/MicrosoftReportProjectsforVisualStudio/2.6.7/assetbyname/Microsoft.DataTools.ReportingServices.vsix
FileName : Microsoft.DataTools.ReportingServices.vsix
All flags value are available here
Thanks to m4js7er and Adam Haynes for inspiration
Adding to t3chb0t's excellent answer - Use these PowerShell commands to install all VSCode extensions in a folder:
cd C:\PathToFolderWithManyDownloadedExtensionFiles
Get-ChildItem . -Filter *.vsix | ForEach-Object { code --install-extension $_.FullName }
Then, reload VSCode to complete the installation.
adding on to t3chb0t's answer, not sure why the option to download is not visible, so created a patch for those who use GreaseMonkey/ TamperMonkey: you can find the gist code here
Or you can just paste the below lines in your browser console, and the link would magically appear:
let version = document.querySelector('.ux-table-metadata > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(2) > div:nth-child(1)').innerText
, itemDetails = window.location.search.replace('?', '').split('&').filter(str => !str.indexOf('itemName')).map(str => str.split('=')[1])[0]
, [author, extension] = itemDetails.split('.')
, lAuthor = author.toLowerCase()
, href = `https://${lAuthor}.gallery.vsassets.io:443/_apis/public/gallery/publisher/${author}/extension/${extension}/${version}/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage`
, element = document.createElement('a');
element.href = href;
element.className = 'vscode-moreinformation dark';
element.innerHTML = 'download .vsix file';
element.download = `${extension}.${version}.vsix`;
document.querySelector('.vscode-install-info-container').appendChild(element);