Last active
August 18, 2017 02:42
-
-
Save h1romas4/eca9a4344ed308a7a0019b284359aa05 to your computer and use it in GitHub Desktop.
VSCode の拡張をオフラインインストール用に .vsix ファイルでダウンロードする (require Internet Explorer)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Download VScode extention .vsix | |
# https://code.visualstudio.com/docs/editor/extension-gallery#_common-questions | |
# | |
Param($extention_site = "https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell") | |
$ErrorActionPreference = "stop" | |
# setting extention site | |
$res = Invoke-WebRequest -Uri $extention_site | |
# parse html | |
$arr = @() | |
$res.ParsedHtml.getElementsByClassName("ux-table-metadata")[0].innerText -split "`n" | ForEach-Object { | |
if($_ -match "[0-9a-zA-z]+") { | |
$arr += $_.Trim() | |
} | |
} | |
$version = $arr[1] | |
$uid = $arr[7] | |
$sp = $uid.Split(".") | |
$publisher = $sp[0] | |
$extensionname = $sp[1] | |
$download_url = "http://${publisher}.gallery.vsassets.io/_apis/public/gallery/publisher/${publisher}/extension/${extensionname}/${version}/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage" | |
# download .vsxi file | |
$filename = "${uid}-$version.vsix" | |
#Write-Host "Download: ${filename}" | |
#Write-Host $download_url | |
#$start_time = Get-Date | |
Invoke-WebRequest -Uri $download_url -OutFile $filename | |
#Write-Output "Time taken: $((Get-Date).Subtract($start_time).Seconds) second(s)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment