195

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 command line if I have the .vsix, but I don't know how to get the .vsix from the marketplace.

How can I download the .vsix for an extension hosted on the marketplace?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
blachniet
  • 4,323
  • 5
  • 33
  • 34
  • Use [download-vsix](https://github.com/rajasimon/download-vsix) download the vsix. i.e) https://rajasimon.github.io/download-vsix?publisher=publisher&extension=extension&version=version – Raja Simon Apr 22 '18 at 19:12

15 Answers15

303

UPDATE 2017-12-13

You can now download the extension directly from the marketplace.

Enter image description here

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:

  • open the extensions sidebar
  • click on the ellipsis in the right upper corner
  • choose Install from VSIX

Install from VSIX...


Old Method

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

  • the publisher name
  • the version
  • the extension name

You can find all this information in the URL.

Example

Here's an example for downloading an installing the C# v1.3.0 extension:

Publisher, Extension and Version

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.

Installation

In order to install the extension

  • Rename the file and give it the *.vsix extension
  • Open Visual Studio Code, go to menu FileOpen File... or Ctrl + O and select the .vsix file
  • If everything went fine, you should see this message at the top of the window:

Extension was successfully installed. Restart to enable it.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
t3chb0t
  • 16,340
  • 13
  • 78
  • 118
  • 11
    I made a bookmarklet to use on the extension page. Let's see how long it stays working!: `javascript:(function() {var ver = document.querySelector("[data-bind='text: version']").innerText; var pub = window.location.href.replace(/.*itemName=(.*?)\.(.*)/,"$1"); var name = window.location.href.replace(/.*itemName=(.*?)\.(.*)/,"$2"); window.location = "https://" + pub + ".gallery.vsassets.io/_apis/public/gallery/publisher/" + pub + "/extension/" + name + "/" + ver + "/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage";})()` – TheQuickBrownFox Aug 10 '16 at 11:09
  • 1
    The installation step didn't work for me, in VS Code 1.7.1 (October 2016). – Roy Dictus Nov 15 '16 at 12:16
  • @RoyDictus ideed, VSCode show the link to the extensions instead of installing it :-| they must have changed something. – t3chb0t Nov 15 '16 at 12:24
  • @RoyDictus see the update - this should work for you. I'll attach screenshots another time. – t3chb0t Nov 15 '16 at 12:27
  • When installing the csharp extension offline it prompts me to restart vscode. When restarting I get the following in the output panel, any ideas?: > Downloading package 'OmniSharp (.NET 4.6 / x64)' Failed at stage: downloadPackages > Error: getaddrinfo ENOTFOUND omnisharpdownload.blob.core.windows.net omnisharpdownload.blob.core.windows.net:443 > > Finished > [ERROR]: C# Extension failed to install the debugger package – Fredrik Hu Nov 21 '16 at 09:16
  • Nice but partially redundant as VSCode now provide the link on their website – Blowsie Dec 01 '17 at 11:50
  • @Blowsie I know but usually you are more likely to find the answer on SO than in the docs and most of the SO answers can be found in docs anyway like what's difference between `String` and `string` in C# - with hundreds of clicks - isn't this silly? ;-) – t3chb0t Dec 01 '17 at 11:56
  • Might be worth updating / deleting half of your answer :) – Blowsie Dec 01 '17 at 12:15
  • Thank you, This helped me today to rollback to ms-vscode.csharp-1.14.0, The new versions are completely broken – Anass May 16 '18 at 08:03
  • What about dependencies? I don't see a "Dependencies" tab on the online marketplace. For example, Debugger for Java by Microsoft has a dependency on Language Support for Java by Red Hat but I don't see that listed on the online page. It is however listed within the VSCode Marketplace tab. – Ebsan Dec 14 '18 at 15:25
  • 2
    This answer has good information; however, C# is a bad example, especially since the question states *"a machine that is not, and cannot be, connected to the internet"*. The C# extension cannot be installed offline as described here because it tries to download platform-specific components after activation, and instead [a specific offline package must be built](https://github.com/OmniSharp/omnisharp-vscode/wiki/Installing-the-C%23-extension-to-a-computer-without-internet-connectivity). – Herohtar Feb 05 '19 at 20:44
  • @Herohtar it's just an example and there is no _asdf_ package ;-P thanks for the link to the article. Btw, I don't really like the C# component because after you've installed it, VSCode updates it on every occasion. Even if you are working wi JavaScript it still likes to open the console and download updates. – t3chb0t Feb 06 '19 at 06:42
  • This isn't always the case, but when you type in the extension name, there is a chance that the name you see in the marketplace isn't what you actually need; you need to look for the "unique identifier" which may or may not be the same as the extension name. This "unique identifier" is what you need to use in the link to download the .VSIXPackage. You can find the "unique identifier" in the "more info" side-bar to the right. – Sphoorthy Nutulapati Sep 26 '19 at 10:41
  • You should edit your answer and tell that now the downloads are available in the version history and no longer there where the screenshot is showing. – Munchkin Apr 04 '22 at 07:46
  • It works for latest version only. – Parameshwar Oct 19 '22 at 08:52
19

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);
AtliB
  • 1,263
  • 1
  • 18
  • 30
mido
  • 24,198
  • 15
  • 92
  • 117
16

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/

slfan
  • 8,950
  • 115
  • 65
  • 78
Yaakov Chaikin
  • 161
  • 1
  • 3
  • Nice but redundant as VSCode now provide the link on their website – Blowsie Dec 01 '17 at 11:49
  • 1
    Correct. That's a very recent addition on their part. I will probably take my service down in the near future. – Yaakov Chaikin Dec 04 '17 at 03:38
  • @YaakovChaikin the link doesn't always show up, but your service works consistently – kbolino Mar 20 '18 at 17:11
  • 2
    This is cool. Unfortunately when others did similar things on GitHub pages instead of Heroku, users like ChrisF deleted them saying "don't link to your GitHub". It's sad when moderators become bullies. – iconoclast Feb 02 '19 at 19:06
6

I wanted to throw a PowerShell download option on the pile in case anyone else comes across this. I have several offline scenarios and I run this in a loop to download and update all of the extensions I use offline.

$page = Invoke-WebRequest -Uri 'https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell'

$details = ( $page.Scripts | ? {$_.class -eq 'vss-extension'}).innerHTML | Convertfrom-Json

$extensionName = $details.extensionName 
$publisher     = $details.publisher.publisherName
$version       = $details.versions.version

Invoke-WebRequest -uri "$($details.versions.fallbackAssetUri)/Microsoft.VisualStudio.Services.VSIXPackage" `
                  -OutFile "C:\Scripts\extensions\$publisher.$extensionName.$version.VSIX"
Adam Haynes
  • 61
  • 1
  • 1
  • Thank you Adam H!!! I came here for comments like this. I need to install extensions via command line on a lot of lab computers. I have not tried this yet but thank you and I'll post another reply in a few days when I try this. Mostly I love the old simplicity of bat files but I need to learn powershell. – Joe Rowe Aug 29 '23 at 16:27
6

As of today the download URL for the latest version of the extension is embedded verbatim in the source of the page on Marketplace, e.g. source at URL:

https://marketplace.visualstudio.com/items?itemName=lukasz-wronski.ftp-sync

contains string:

https://lukasz-wronski.gallerycdn.vsassets.io/extensions/lukasz-wronski/ftp-sync/0.3.3/1492669004156/Microsoft.VisualStudio.Services.VSIXPackage

I use following Python regexp to extract dl URL:

urlre = re.search(r'source.+(http.+Microsoft\.VisualStudio\.Services\.VSIXPackage)', content)
if urlre:
    return urlre.group(1)
LetMeSOThat4U
  • 6,470
  • 10
  • 53
  • 93
  • Dear Person named LetMeSolve that for you, Thank you. I will try your solution and check back in soon. – Joe Rowe Aug 29 '23 at 16:34
6

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.

Oren Chapo
  • 519
  • 7
  • 15
4

From version history tab extension can be downloaded

enter image description here

Hisham Shahid
  • 225
  • 3
  • 7
3

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.

Quick steps:

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.

Detailed steps:

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 or Untick Update as shown. This prevents VSCode from reaching out to the internet and auto-updating your versions to the latest.

enter image description here

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.

Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
petah
  • 320
  • 3
  • 13
2

I've stored a script in my gist to download an extension from the marketplace using a PowerShell script. Feel free to comment of share it.

https://gist.github.com/azurekid/ca641c47981cf8074aeaf6218bb9eb58

[CmdletBinding()]
param
(
    [Parameter(Mandatory = $true)]
    [string] $Publisher,

    [Parameter(Mandatory = $true)]
    [string] $ExtensionName,

    [Parameter(Mandatory = $true)]
    [ValidateScript( {
            If ($_ -match "^([0-9].[0-9].[0-9])") {
                $True
            }
            else {
                Throw "$_ is not a valid version number. Version can only contain digits"
            }
        })]
    [string] $Version,

    [Parameter(Mandatory = $true)]
    [string] $OutputLocation
)

Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"

Write-Output "Publisher:        $($Publisher)"
Write-Output "Extension name:   $($ExtensionName)"
Write-Output "Version:          $($Version)"
Write-Output "Output location   $($OutputLocation)"

$baseUrl = "https://$($Publisher).gallery.vsassets.io/_apis/public/gallery/publisher/$($Publisher)/extension/$($ExtensionName)/$($Version)/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage"
$outputFile = "$($Publisher)-$($ExtensionName)-$($Version).visx"

if (Test-Path $OutputLocation) {
    try {
        Write-Output "Retrieving extension..."
        [uri]::EscapeUriString($baseUrl) | Out-Null
        Invoke-WebRequest -Uri $baseUrl -OutFile "$OutputLocation\$outputFile"
    }
    catch {
        Write-Error "Unable to find the extension in the marketplace"
    }
}
else {
    Write-Output "The Path $($OutputLocation) does not exist"
}
Azurekid
  • 21
  • 1
  • 1
    The url structure has changed, it is now `"https://marketplace.visualstudio.com/_apis/public/gallery/publishers/${Publisher}/vsextensions/${ExtensionName}/${Version}/vspackage"` – Aviad P. Jul 18 '21 at 13:02
1

Now you can download an extension directly in the "Resources" section, there's a "Download extension" link, I hope this information is still useful.

Luis
  • 41
  • 1
  • 7
1

If you are looking for a scripted solution:

  1. Get binary download URL: you can use an API, but be warned that there is no documentation for it. This API can return an URL to download .vsix files (see example below)
  2. Download the binary
  3. Carefully unzip the binary into ~/.vscode/extensions/: you need to modify unzipped directory name, remove one file and move/rename another one.

For API start by looking at following example, and for hints how to modify request head to https://github.com/Microsoft/vscode/blob/master/src/vs/platform/extensionManagement/common/extensionGalleryService.ts.

POST https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery?api-version=5.1-preview HTTP/1.1
content-type: application/json

{
    "filters": [
        {
        "criteria": [
            {
                "filterType": 8,
                "value": "Microsoft.VisualStudio.Code",
            },
            {
                "filterType": 7,
                "value": "ms-python.python",
            }
        ],
        "pageNumber": 1,
        "pageSize": 10,
        "sortBy": 0,
        "sortOrder": 0,
        }
    ],
    "assetTypes": ["Microsoft.VisualStudio.Services.VSIXPackage"],
    "flags": 514,
}

Explanations to the above example:

  • "filterType": 8 - FilterType.Target more FilterTypes
  • "filterType": 7 - FilterType.ExtensionName more FilterTypes
  • "flags": 514 - 0x2 | 0x200 - Flags.IncludeFiles | Flags.IncludeLatestVersionOnly - more Flags
    • to get flag decimal value you can run python -c "print(0x2|0x200)"
  • "assetTypes": ["Microsoft.VisualStudio.Services.VSIXPackage"] - to get only link to .vsix file more AssetTypes
Nuno André
  • 4,739
  • 1
  • 33
  • 46
m4js7er
  • 119
  • 1
  • 3
1

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

Cedric
  • 11
  • 1
1

Indeed it baffles me that there is no direct curl-friendly URL provided on Marketplace Webpage to download a vscode extension! I need that to populate a container in a CICD pipeline.

I found the answers by @t3chb0t and @LetMeSOThat4U very useful here. In addition, I found that:

  1. The actual package is either named vspackage or named Microsoft.VisualStudio.Services.VSIXPackage (any others?). There is a tag VsixManifestAssetType I think one can use to get the type: "VsixManifestAssetType":"Microsoft.VisualStudio.Services.VsixManifest"

  2. These artifacts are tar file. So if you have download vspackage, to see the content: tar vtf vspackage

  3. Now supposedly, an extension jupyter should have .vsix suffix, but none of these packages are named with .vsix. So I think after download, one has to rename the package to .vsix accordingly. With jupyter version 2021.7.0, I'll rename the vspackage to something like: vsx-jupyter-2021.7.0.vsix

  4. On Linux/Ubuntu: I can use the following command to install it: $ code-server --install-extensions vsx-jupyter-2021.7.0.vsix. Afterward, one can use: code-server --list-extensions to verify.

  5. To get the URL of the package ms-python, follow @LetMeSOThat4U method:

a. Use Chrome browser or curl/wget to get the page https://marketplace.visualstudio.com/items?itemName=ms-python.python

b. Right click mouse to select View Page Source and search for string: "AssetUri": You'll see "AssetUri":"https://ms-python.gallerycdn.vsassets.io/extensions/ms-python/python/2021.6.944021595/1623882641726"

c. Now try to append either vspackage or Microsoft.VisualStudio.Services.VSIXPackage and see which one works. In this case, it is latter, from the VsixManifestAssetType. So the actual CLI using curl: $ curl -o vsx-ms-python-2021.6.vsix --insecure https://ms-python.gallerycdn.vsassets.io/extensions/ms-python/python/2021.6.944021595/1623882641726/Microsoft.VisualStudio.Services.VSIXPackage

$ tar vtf vsx-ms-python-2021.6.vsix # would show the content of the file

HAltos
  • 701
  • 7
  • 6
0

For Python users the pattern to use with t3chbot's excellent answer looks like:

https://marketplace.visualstudio.com/_apis/public/gallery/publishers/ms-python/vsextensions/python/{version_number}/vspackage

be sure to scroll right to see where you have to enter the version number.

Little Bobby Tables
  • 4,466
  • 4
  • 29
  • 46
0

Another update, combining some of the above to get a script that downloads a vsix for all installed extensions

[CmdLetBinding()]
Param (
    $Path = "H:\Extensions"
)

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) {
            write-verbose "getting $($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 "API Error :  $($response.StatusDescription)"
                return
            }
            $ObjResults = ($response.Content | ConvertFrom-Json).results

            If ($ObjResults.resultMetadata.metadataItems.count -ne 1) {
                Write-Warning "Extension not found"
                return
            }

            $extension = $ObjResults.extensions

            $publisher = $extension.publisher.publisherName
            $extensionName = $extension.extensionName
            $version = $extension.versions[0].version

            $uri = "$($extension.Versions[0].assetUri)/Microsoft.VisualStudio.Services.VSIXPackage"
            Invoke-WebRequest -uri $uri -OutFile (Join-Path $Path "$publisher.$extensionName.$version.VSIX")
        }
    }
}

Invoke-Expression "code --list-extensions" -OutVariable extensions | Out-Null
$extensions | Get-VSMarketPlaceExtension
David Wallis
  • 185
  • 11