47
47
48
48
https://github.com/PowerShell/vscode-powershell/blob/develop/scripts/Install-VSCode.ps1
49
49
50
+ . PARAMETER Architecture
51
+ A validated string defining the bit version to download. Values can be either 64 or 32.
52
+ If 64 is chosen and the OS Architecture does not match, then the x86 build will be
53
+ downloaded instead. If parameter is not used, then 64-bit is used as default.
54
+
50
55
. PARAMETER BuildEdition
51
56
A validated string defining which build edition or "stream" to download - stable or
52
57
insiders edition. If the parameter is not used, then stable is downloaded as default.
62
67
When present, causes Visual Studio Code to be launched as soon as installation
63
68
has finished.
64
69
70
+ . EXAMPLE
71
+ Install-VSCode.ps1 -Architecture 32
72
+
73
+ Installs Visual Studio Code (32-bit) and the powershell extension.
65
74
. EXAMPLE
66
75
Install-VSCode.ps1 -LaunchWhenDone
67
76
68
- Installs Visual Studio Code and the PowerShell extension and then launches
77
+ Installs Visual Studio Code (64-bit) and the PowerShell extension and then launches
69
78
the editor after installation completes.
70
79
71
80
. EXAMPLE
72
81
Install-VSCode.ps1 -AdditionalExtensions 'eamodio.gitlens', 'vscodevim.vim'
73
82
74
- Installs Visual Studio Code, the PowerShell extension, and additional
83
+ Installs Visual Studio Code (64-bit) , the PowerShell extension, and additional
75
84
extensions.
76
85
77
86
. EXAMPLE
78
87
Install-VSCode.ps1 -BuildEdition Insider -LaunchWhenDone
79
88
80
- Installs Visual Studio Code Insiders Edition and then launches the editor
89
+ Installs Visual Studio Code Insiders Edition (64-bit) and then launches the editor
81
90
after installation completes.
82
91
83
92
. NOTES
105
114
#>
106
115
[CmdletBinding ()]
107
116
param (
117
+ [parameter ()]
118
+ [ValidateSet (, " 64" , " 32" )]
119
+ [string ]$Architecture = " 64" ,
120
+
108
121
[parameter ()]
109
122
[ValidateSet (" stable" , " insider" )]
110
123
[string ]$BuildEdition = " stable" ,
@@ -117,25 +130,41 @@ param(
117
130
)
118
131
119
132
if (! ($IsLinux -or $IsOSX )) {
133
+ switch ($Architecture ) {
134
+ " 64" {
135
+ if ((Get-WmiObject - Class Win32_OperatingSystem).OSArchitecture -eq " 64-bit" ) {
136
+ $codePath = $env: ProgramFiles
137
+ $bitVersion = " win32-x64"
138
+ }
139
+ else {
140
+ $codePath = ${env: ProgramFiles(x86)}
141
+ $bitVersion = " win32"
142
+ }
143
+ break ;
144
+ }
145
+ " 32" {
146
+ $codePath = ${env: ProgramFiles(x86)}
147
+ $bitVersion = " win32"
148
+ break ;
149
+ }
150
+ }
120
151
switch ($BuildEdition ) {
121
152
" Stable" {
122
- $codeCmdPath = " C:\Program* \Microsoft VS Code\bin\code.cmd"
153
+ $codeCmdPath = " $codePath \Microsoft VS Code\bin\code.cmd"
123
154
break ;
124
155
}
125
156
" Insider" {
126
- $codeCmdPath = " C:\Program* \Microsoft VS Code Insiders\bin\code-insiders.cmd"
157
+ $codeCmdPath = " $codePath \Microsoft VS Code Insiders\bin\code-insiders.cmd"
127
158
break ;
128
159
}
129
160
}
130
-
131
-
132
161
try {
133
162
$ProgressPreference = ' SilentlyContinue'
134
163
135
164
if (! (Test-Path $codeCmdPath )) {
136
165
Write-Host " `n Downloading latest $ ( $BuildEdition ) Visual Studio Code..." - ForegroundColor Yellow
137
166
Remove-Item - Force " $env: TEMP \vscode-$ ( $BuildEdition ) .exe" - ErrorAction SilentlyContinue
138
- Invoke-WebRequest - Uri " https://vscode-update.azurewebsites.net/latest/win32-x64 /$ ( $BuildEdition ) " - OutFile " $env: TEMP \vscode-$ ( $BuildEdition ) .exe"
167
+ Invoke-WebRequest - Uri " https://vscode-update.azurewebsites.net/latest/$ ( $bitVersion ) /$ ( $BuildEdition ) " - OutFile " $env: TEMP \vscode-$ ( $BuildEdition ) .exe"
139
168
140
169
Write-Host " `n Installing Visual Studio Code..." - ForegroundColor Yellow
141
170
Start-Process - Wait " $env: TEMP \vscode-$ ( $BuildEdition ) .exe" - ArgumentList / silent, / mergetasks= ! runcode
0 commit comments