|
1 | 1 | <#PSScriptInfo
|
2 | 2 |
|
3 |
| -.VERSION 1.0 |
| 3 | +.VERSION 1.1 |
4 | 4 |
|
5 | 5 | .GUID 539e5585-7a02-4dd6-b9a6-5dd288d0a5d0
|
6 | 6 |
|
|
25 | 25 | .EXTERNALSCRIPTDEPENDENCIES
|
26 | 26 |
|
27 | 27 | .RELEASENOTES
|
| 28 | + 28/12/2017 - added functionality to support 64-bit versions of VSCode |
| 29 | + & support for installation of VSCode Insiders Edition. |
| 30 | + -- |
28 | 31 | Initial release.
|
29 | 32 | #>
|
30 | 33 |
|
|
44 | 47 |
|
45 | 48 | https://github.com/PowerShell/vscode-powershell/blob/develop/scripts/Install-VSCode.ps1
|
46 | 49 |
|
| 50 | +.PARAMETER BuildEdition |
| 51 | + A validated string defining which build edition or "stream" to download - stable or |
| 52 | + insiders edition. If the parameter is not used, then stable is downloaded as default. |
| 53 | +
|
47 | 54 | .PARAMETER AdditionalExtensions
|
48 | 55 | An array of strings that are the fully-qualified names of extensions to be
|
49 | 56 | installed in addition to the PowerShell extension. The fully qualified
|
|
67 | 74 | Installs Visual Studio Code, the PowerShell extension, and additional
|
68 | 75 | extensions.
|
69 | 76 |
|
| 77 | +.EXAMPLE |
| 78 | + Install-VSCode.ps1 -BuildEdition Insider -LaunchWhenDone |
| 79 | +
|
| 80 | + Installs Visual Studio Code Insiders Edition and then launches the editor |
| 81 | + after installation completes. |
| 82 | +
|
70 | 83 | .NOTES
|
71 | 84 | This script is licensed under the MIT License:
|
72 | 85 |
|
|
92 | 105 | #>
|
93 | 106 | [CmdletBinding()]
|
94 | 107 | param(
|
| 108 | + [parameter()] |
| 109 | + [ValidateSet("stable","insider")] |
| 110 | + [string]$BuildEdition = "stable", |
95 | 111 | [Parameter()]
|
96 | 112 | [ValidateNotNull()]
|
97 | 113 | [string[]]$AdditionalExtensions = @(),
|
98 |
| - |
99 | 114 | [switch]$LaunchWhenDone
|
100 | 115 | )
|
101 | 116 |
|
102 | 117 | if (!($IsLinux -or $IsOSX)) {
|
| 118 | + switch ($BuildEdition) { |
| 119 | + "Stable" { |
| 120 | + $codeCmdPath = "C:\Program*\Microsoft VS Code\bin\code.cmd" |
| 121 | + break; |
| 122 | + } |
| 123 | + "Insider" { |
| 124 | + $codeCmdPath = "C:\Program*\Microsoft VS Code Insiders\bin\code-insiders.cmd" |
| 125 | + break; |
| 126 | + } |
| 127 | + } |
103 | 128 |
|
104 |
| - $codeCmdPath = "C:\Program Files (x86)\Microsoft VS Code\bin\code.cmd" |
105 | 129 |
|
106 | 130 | try {
|
107 | 131 | $ProgressPreference = 'SilentlyContinue'
|
108 | 132 |
|
109 | 133 | if (!(Test-Path $codeCmdPath)) {
|
110 |
| - Write-Host "`nDownloading latest stable Visual Studio Code..." -ForegroundColor Yellow |
111 |
| - Remove-Item -Force $env:TEMP\vscode-stable.exe -ErrorAction SilentlyContinue |
112 |
| - Invoke-WebRequest -Uri https://vscode-update.azurewebsites.net/latest/win32/stable -OutFile $env:TEMP\vscode-stable.exe |
| 134 | + Write-Host "`nDownloading latest $($BuildEdition) Visual Studio Code..." -ForegroundColor Yellow |
| 135 | + Remove-Item -Force "$env:TEMP\vscode-$($BuildEdition).exe" -ErrorAction SilentlyContinue |
| 136 | + Invoke-WebRequest -Uri "https://vscode-update.azurewebsites.net/latest/win32-x64/$($BuildEdition)" -OutFile "$env:TEMP\vscode-$($BuildEdition).exe" |
113 | 137 |
|
114 | 138 | Write-Host "`nInstalling Visual Studio Code..." -ForegroundColor Yellow
|
115 |
| - Start-Process -Wait $env:TEMP\vscode-stable.exe -ArgumentList /silent, /mergetasks=!runcode |
| 139 | + Start-Process -Wait "$env:TEMP\vscode-$($BuildEdition).exe" -ArgumentList /silent, /mergetasks=!runcode |
116 | 140 | }
|
117 | 141 | else {
|
118 | 142 | Write-Host "`nVisual Studio Code is already installed." -ForegroundColor Yellow
|
|
0 commit comments