How can I install Visual Studio Code extensions offline?

后端 未结 12 1205
终归单人心
终归单人心 2020-11-27 09:12

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

12条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-27 10:05

    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"
    

提交回复
热议问题