-
-
Save The-Running-Dev/b7c29e1c0889ba2e59949d5093bd9def to your computer and use it in GitHub Desktop.
Unattended install of Wix Toolset Visual Studio 2017 Extension
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
$extensionDisplayName = "Wix Toolset Visual Studio 2017 Extension"; | |
$extensionApiVersion = "api-version=3.2-preview.1" | |
$marketplaceQueryUrl = "https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery"; | |
$extensionQuery = "{`"flags`":`"262`"," + | |
"`"filters`":[" + | |
"{" + | |
"`"criteria`":" + | |
"[" + | |
"{`"filterType`":`"14`",`"value`":`"1033`"}," + | |
"{`"filterType`":`"8`",`"value`":`"Microsoft.VisualStudio.Community`"}," + | |
"{`"filterType`":`"10`",`"value`":`"$extensionDisplayName`"}" + | |
"]," + | |
"`"sortBy`":`"0`"," + | |
"`"sortOrder`":`"2`"," + | |
"`"pageSize`":`"1`"," + | |
"`"pageNumber`":`"1`"" + | |
"}" + | |
"]" + | |
"}" | |
$webClient = New-Object System.Net.WebClient | |
$webClient.Headers["Accept"] = "application/json; $extensionApiVersion"; | |
$webClient.Headers["Content-Type"] = "application/json; charset=utf-8"; | |
$extensionQueryResponse = $webClient.UploadString($marketplaceQueryUrl, $extensionQuery); | |
$extensionQueryResponsJson = $extensionQueryResponse | ConvertFrom-Json | |
$extensionUrl = $extensionQueryResponsJson.results[0].extensions[0].versions[0].files | Where-Object { $_.assetType.EndsWith(".vsix")} | Select-Object -ExpandProperty source -First 1; | |
$extensionFileName = [IO.Path]::GetFileName($extensionUrl) | |
$extensionFilePath = ".\$extensionFileName" | |
if(Test-Path $extensionFilePath){ | |
Remove-Item $extensionFilePath -Force | |
} | |
(New-Object System.Net.WebClient).DownloadFile($extensionUrl, $extensionFilePath) | |
$vsixInstaller = Get-ChildItem -Path "$(${env:ProgramFiles(x86)})\Microsoft Visual Studio" | | |
? { !$PsIsContainer -and $_.Name.StartsWith("20") } | | |
% { @( | |
[System.IO.Path]::Combine($_.FullName, "Enterprise", "Common7\IDE"), | |
[System.IO.Path]::Combine($_.FullName, "Professional", "Common7\IDE"), | |
[System.IO.Path]::Combine($_.FullName, "Community", "Common7\IDE")) | |
} | | |
? { (Test-Path -Path $_) } | | |
% { Get-ChildItem -Path $_ | ? { !$PsIsContainer -and $_.Name.Equals("VSIXInstaller.exe", "OrdinalIgnoreCase") } } | | |
Select-Object -ExpandProperty FullName -First 1 | |
$sku = Get-ChildItem -Path "$(${env:ProgramFiles(x86)})\Microsoft Visual Studio" | | |
? { !$PsIsContainer -and $_.Name.StartsWith("20") } | | |
% { @( | |
[System.IO.Path]::Combine($_.FullName, "Enterprise"), | |
[System.IO.Path]::Combine($_.FullName, "Professional"), | |
[System.IO.Path]::Combine($_.FullName, "Community")) | |
} | | |
? { (Test-Path -Path $_) } | Select-Object { (New-Object System.IO.DirectoryInfo($_)).Name } -First 1; | |
$installProcess = Start-Process ` | |
-FilePath "$(${env:ProgramFiles(x86)})\Microsoft Visual Studio\2017\Community\Common7\IDE\VSIXInstaller.exe" ` | |
-Wait ` | |
-ArgumentList @( | |
"/q", | |
"/skuName:$sku", | |
"/skuVersion:15.0", | |
"$extensionFilePath" | |
) | |
if(Test-Path $extensionFilePath){ | |
Remove-Item $extensionFilePath -Force | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment