|
| 1 | +# Copyright (c) 2018 The nanoFramework project contributors |
| 2 | +# See LICENSE file in the project root for full license information. |
| 3 | + |
| 4 | + |
| 5 | +# choco install wixtoolset -y --force |
| 6 | + |
| 7 | +# #Installing VS extension 'Wix Toolset Visual Studio 2017 Extension' |
| 8 | +# Install-VsixExtension -Url 'https://marketplace.visualstudio.com/_apis/public/gallery/publishers/vs-publisher-1470366/vsextensions/nanoFrameworkVS2017Extension/0/vspackage' -Name 'nanoFramework.Tools.VS2017.Extension.vsix' |
| 9 | + |
| 10 | + |
| 11 | +# # install VSSetup PS module (https://github.com/Microsoft/vssetup.powershell) |
| 12 | +# 'Installing VSSetup module ...' | Write-Host -ForegroundColor White |
| 13 | +# Install-Module VSSetup -Scope CurrentUser -AcceptLicense -Force |
| 14 | + |
| 15 | +# # get Visual Studio install path |
| 16 | +# $vsInstallPath = Get-VSSetupInstance ` |
| 17 | +# | Select-VSSetupInstance ` |
| 18 | +# | Select-Object -ExpandProperty InstallationPath |
| 19 | + |
| 20 | +# # extension path |
| 21 | +# $vsixPath = Join-Path $env:Agent_TempDirectory "nanoFramework.Tools.VS2017.Extension.vsix" |
| 22 | + |
| 23 | +# "Downloading extension from marketplace..." | Write-Host -ForegroundColor White |
| 24 | + |
| 25 | +# # # download extension from marketplace |
| 26 | +# $FileUrl = 'https://marketplace.visualstudio.com/_apis/public/gallery/publishers/vs-publisher-1470366/vsextensions/nanoFrameworkVS2017Extension/0/vspackage' |
| 27 | +# # (New-Object Net.WebClient).DownloadFile('https://marketplace.visualstudio.com/_apis/public/gallery/publishers/vs-publisher-1470366/vsextensions/nanoFrameworkVS2017Extension/0/vspackage', $vsixPath) |
| 28 | + |
| 29 | +# $start_time = Get-Date |
| 30 | +# Invoke-WebRequest -Uri "$FileUrl" -OutFile $vsixPath -UseDefaultCredentials -UseBasicParsing |
| 31 | +# Write-Host "Time taken to download: $((Get-Date).Subtract($start_time).Seconds) second(s)" |
| 32 | + |
| 33 | +# # $installScript = Join-Path $env:Agent_TempDirectory "install-vsix.cmd" |
| 34 | + |
| 35 | +$Url = "https://vs-publisher-1470366.gallerycdn.vsassets.io/extensions/vs-publisher-1470366/nanoframeworkvs2017extension/1.0.0.0/1539707795657/nanoFramework.Tools.VS2017.Extension.vsix" |
| 36 | +$Name = "nanoFramework.Tools.VS2017.Extension.vsix" |
| 37 | + |
| 38 | +Write-Host "Downloading $Name..." |
| 39 | +$FilePath = "${env:Temp}\$Name" |
| 40 | + |
| 41 | +Invoke-WebRequest -Uri $Url -OutFile $FilePath |
| 42 | + |
| 43 | +$ArgumentList = ('/quiet', $FilePath) |
| 44 | + |
| 45 | +Write-Host "Starting Install $Name..." |
| 46 | +$process = Start-Process -FilePath 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VSIXInstaller.exe' -ArgumentList $ArgumentList -Wait -PassThru -NoNewWindow |
| 47 | +$exitCode = $process.ExitCode |
| 48 | + |
| 49 | +if ($exitCode -eq 0 -or $exitCode -eq 3010) |
| 50 | +{ |
| 51 | + Write-Host -Object 'Installation successful' |
| 52 | + return $exitCode |
| 53 | +} |
| 54 | +else |
| 55 | +{ |
| 56 | + Write-Host -Object "Non zero exit code returned by the installation process : $exitCode." |
| 57 | + return $exitCode |
| 58 | +} |
| 59 | + |
| 60 | +# install on process with timeout |
| 61 | +# Write-Host "Starting Install $Name..." |
| 62 | + |
| 63 | +# $proc = Start-Process -FilePath 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VSIXInstaller.exe' -ArgumentList $ArgumentList -Wait -PassThru |
| 64 | + |
| 65 | +# # keep track of timeout event |
| 66 | +# $timeouted = $null # reset any previously set timeout |
| 67 | + |
| 68 | +# # wait up to 4 minutes (4 * 60 = 240 seconds) for normal termination |
| 69 | +# $proc | Wait-Process -Timeout 240 -ErrorAction SilentlyContinue -ErrorVariable timeouted |
| 70 | + |
| 71 | +# if ($timeouted) |
| 72 | +# { |
| 73 | +# # terminate the process |
| 74 | +# $proc | kill |
| 75 | + |
| 76 | +# # update internal error counter |
| 77 | +# } |
| 78 | +# elseif ($proc.ExitCode -ne 0) |
| 79 | +# { |
| 80 | +# # update internal error counter |
| 81 | +# } |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | +# ("`"$vsInstallPath\Common7\IDE\VSIXInstaller.exe`" /q $vsixPath" | Out-File $installScript -Encoding ASCII) |
| 86 | + |
| 87 | +# # "`"$vsInstallPath\Common7\IDE\VSIXInstaller.exe`" /q /a $vsixPath" | out-file ".\install-vsix.cmd" -Encoding ASCII |
| 88 | +# Start-Process -FilePath "$vsInstallPath\Common7\IDE\VSIXInstaller.exe" -ArgumentList "/q $extension" -Wait -PassThru |
| 89 | + |
| 90 | +# 'Installing nanoFramework VS extension ...' | Write-Host -ForegroundColor White -NoNewline |
| 91 | +# Invoke-Expression "& '$env:ComSpec' '$installScript'" |
| 92 | +# Invoke-Expression "& '$installScript'" |
| 93 | + |
| 94 | +# 'OK' | Write-Host -ForegroundColor Green |
0 commit comments