-
Notifications
You must be signed in to change notification settings - Fork 70
/
install_vs2019.ps1
320 lines (295 loc) · 16 KB
/
install_vs2019.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
#
# The list of VS 2019 components: https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-community?vs-2019&view=vs-2019
#
Function InstallVS
{
Param
(
[String] $WorkLoads,
[String] $Sku,
[String] $VSBootstrapperURL,
[String] $ChannelUri
)
$exitCode = -1
try
{
Write-Host "Downloading Bootstrapper ..."
Invoke-WebRequest -Uri $VSBootstrapperURL -OutFile "${env:Temp}\vs_$Sku.exe"
$FilePath = "${env:Temp}\vs_$Sku.exe"
$Arguments = ($WorkLoads, '--quiet', '--norestart', '--wait', '--nocache')
if ($ChannelUri) {
$Arguments += (
'--channelUri', $ChannelUri,
'--installChannelUri', $ChannelUri
)
}
Write-Host "Starting Install ..."
$process = Start-Process -FilePath $FilePath -ArgumentList $Arguments -Wait -PassThru
$exitCode = $process.ExitCode
if ($exitCode -eq 0 -or $exitCode -eq 3010)
{
Write-Host -Object 'Installation successful'
return $exitCode
}
else
{
Write-Host -Object "Non zero exit code returned by the installation process : $exitCode."
# this wont work because of log size limitation in extension manager
# Get-Content $customLogFilePath | Write-Host
exit $exitCode
}
}
catch
{
Write-Host -Object "Failed to install Visual Studio. Check the logs for details in $customLogFilePath"
Write-Host -Object $_.Exception.Message
exit -1
}
}
$WorkLoads = '--add Component.Android.NDK.R16B ' + `
'--add Component.Android.SDK25.Private ' + `
'--add Component.Android.SDK28 ' + `
'--add Component.Linux.CMake ' + `
'--add Component.MDD.Android ' + `
'--add Component.MDD.Linux ' + `
'--add Component.Microsoft.VisualStudio.RazorExtension ' + `
'--add Component.Microsoft.VisualStudio.Web.AzureFunctions ' + `
'--add Component.Microsoft.Web.LibraryManager ' + `
'--add Component.OpenJDK ' + `
'--add Component.Xamarin ' + `
'--add Component.Xamarin.RemotedSimulator ' + `
'--add Microsoft.Component.Azure.DataLake.Tools ' + `
'--add Microsoft.Component.MSBuild ' + `
'--add Microsoft.Component.NetFX.Native ' + `
'--add Microsoft.Component.VC.Runtime.UCRTSDK ' + `
'--add Microsoft.ComponentGroup.Blend ' + `
'--add Microsoft.Net.Component.3.5.DeveloperTools ' + `
'--add Microsoft.Net.Component.4.5.1.TargetingPack ' + `
'--add Microsoft.Net.Component.4.5.2.TargetingPack ' + `
'--add Microsoft.Net.Component.4.5.TargetingPack ' + `
'--add Microsoft.Net.Component.4.6.1.SDK ' + `
'--add Microsoft.Net.Component.4.6.1.TargetingPack ' + `
'--add Microsoft.Net.Component.4.6.2.SDK ' + `
'--add Microsoft.Net.Component.4.6.2.TargetingPack ' + `
'--add Microsoft.Net.Component.4.6.TargetingPack ' + `
'--add Microsoft.Net.Component.4.7.1.SDK ' + `
'--add Microsoft.Net.Component.4.7.1.TargetingPack ' + `
'--add Microsoft.Net.Component.4.7.2.SDK ' + `
'--add Microsoft.Net.Component.4.7.2.TargetingPack ' + `
'--add Microsoft.Net.Component.4.7.SDK ' + `
'--add Microsoft.Net.Component.4.7.TargetingPack ' + `
'--add Microsoft.Net.Component.4.8.SDK ' + `
'--add Microsoft.Net.Component.4.8.TargetingPack ' + `
'--add Microsoft.Net.Component.4.TargetingPack ' + `
'--add Microsoft.Net.ComponentGroup.4.6.2.DeveloperTools ' + `
'--add Microsoft.Net.ComponentGroup.DevelopmentPrerequisites ' + `
'--add Microsoft.Net.ComponentGroup.TargetingPacks.Common ' + `
'--add Microsoft.NetCore.Component.DevelopmentTools ' + `
'--add Microsoft.NetCore.Component.SDK ' + `
'--add Microsoft.NetCore.Component.Web ' + `
'--add Microsoft.VisualStudio.Component.AppInsights.Tools ' + `
'--add Microsoft.VisualStudio.Component.AspNet45 ' + `
'--add Microsoft.VisualStudio.Component.Azure.AuthoringTools ' + `
'--add Microsoft.VisualStudio.Component.Azure.ClientLibs ' + `
'--add Microsoft.VisualStudio.Component.Azure.Compute.Emulator ' + `
'--add Microsoft.VisualStudio.Component.Azure.ResourceManager.Tools ' + `
'--add Microsoft.VisualStudio.Component.Azure.ServiceFabric.Tools ' + `
'--add Microsoft.VisualStudio.Component.Azure.Storage.Emulator ' + `
'--add Microsoft.VisualStudio.Component.Azure.Waverton ' + `
'--add Microsoft.VisualStudio.Component.Azure.Waverton.BuildTools ' + `
'--add Microsoft.VisualStudio.Component.CloudExplorer ' + `
'--add Microsoft.VisualStudio.Component.Common.Azure.Tools ' + `
'--add Microsoft.VisualStudio.Component.CoreEditor ' + `
'--add Microsoft.VisualStudio.Component.Debugger.JustInTime ' + `
'--add Microsoft.VisualStudio.Component.DiagnosticTools ' + `
'--add Microsoft.VisualStudio.Component.DockerTools ' + `
'--add Microsoft.VisualStudio.Component.EntityFramework ' + `
'--add Microsoft.VisualStudio.Component.FSharp ' + `
'--add Microsoft.VisualStudio.Component.FSharp.Desktop ' + `
'--add Microsoft.VisualStudio.Component.FSharp.WebTemplates ' + `
'--add Microsoft.VisualStudio.Component.Graphics ' + `
'--add Microsoft.VisualStudio.Component.Graphics.Tools ' + `
'--add Microsoft.VisualStudio.Component.IISExpress ' + `
'--add Microsoft.VisualStudio.Component.IntelliCode ' + `
'--add Microsoft.VisualStudio.Component.JavaScript.Diagnostics ' + `
'--add Microsoft.VisualStudio.Component.JavaScript.TypeScript ' + `
'--add Microsoft.VisualStudio.Component.ManagedDesktop.Core ' + `
'--add Microsoft.VisualStudio.Component.ManagedDesktop.Prerequisites ' + `
'--add Microsoft.VisualStudio.Component.Merq ' + `
'--add Microsoft.VisualStudio.Component.MonoDebugger ' + `
'--add Microsoft.VisualStudio.Component.MSODBC.SQL ' + `
'--add Microsoft.VisualStudio.Component.MSSQL.CMDLnUtils ' + `
'--add Microsoft.VisualStudio.Component.Node.Tools ' + `
'--add Microsoft.VisualStudio.Component.NuGet ' + `
'--add Microsoft.VisualStudio.Component.PortableLibrary ' + `
'--add Microsoft.VisualStudio.Component.Roslyn.Compiler ' + `
'--add Microsoft.VisualStudio.Component.Roslyn.LanguageServices ' + `
'--add Microsoft.VisualStudio.Component.Sharepoint.Tools ' + `
'--add Microsoft.VisualStudio.Component.SQL.ADAL ' + `
'--add Microsoft.VisualStudio.Component.SQL.CLR ' + `
'--add Microsoft.VisualStudio.Component.SQL.DataSources ' + `
'--add Microsoft.VisualStudio.Component.SQL.LocalDB.Runtime ' + `
'--add Microsoft.VisualStudio.Component.SQL.SSDT ' + `
'--add Microsoft.VisualStudio.Component.TeamOffice ' + `
'--add Microsoft.VisualStudio.Component.TextTemplating ' + `
'--add Microsoft.VisualStudio.Component.TypeScript.3.6 ' + `
'--add Microsoft.VisualStudio.Component.VC.14.20.ATL ' + `
'--add Microsoft.VisualStudio.Component.VC.14.20.ATL.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.14.20.CLI.Support ' + `
'--add Microsoft.VisualStudio.Component.VC.14.20.MFC ' + `
'--add Microsoft.VisualStudio.Component.VC.14.20.MFC.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.14.20.x86.x64 ' + `
'--add Microsoft.VisualStudio.Component.VC.14.20.x86.x64.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.14.21.ARM ' + `
'--add Microsoft.VisualStudio.Component.VC.14.21.ARM.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.14.21.ARM64 ' + `
'--add Microsoft.VisualStudio.Component.VC.14.21.ARM64.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.14.21.ATL ' + `
'--add Microsoft.VisualStudio.Component.VC.14.21.ATL.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.14.21.CLI.Support ' + `
'--add Microsoft.VisualStudio.Component.VC.14.21.MFC ' + `
'--add Microsoft.VisualStudio.Component.VC.14.21.MFC.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.14.21.x86.x64 ' + `
'--add Microsoft.VisualStudio.Component.VC.14.21.x86.x64.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.14.22.ATL ' + `
'--add Microsoft.VisualStudio.Component.VC.14.22.ATL.ARM ' + `
'--add Microsoft.VisualStudio.Component.VC.14.22.ATL.ARM.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.14.22.ATL.ARM64 ' + `
'--add Microsoft.VisualStudio.Component.VC.14.22.ATL.ARM64.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.14.22.ATL.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.14.22.CLI.Support ' + `
'--add Microsoft.VisualStudio.Component.VC.14.22.MFC ' + `
'--add Microsoft.VisualStudio.Component.VC.14.22.MFC.ARM ' + `
'--add Microsoft.VisualStudio.Component.VC.14.22.MFC.ARM.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.14.22.MFC.ARM64 ' + `
'--add Microsoft.VisualStudio.Component.VC.14.22.MFC.ARM64.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.14.22.MFC.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.14.22.x86.x64 ' + `
'--add Microsoft.VisualStudio.Component.VC.14.22.x86.x64.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.140 ' + `
'--add Microsoft.VisualStudio.Component.VC.ATL ' + `
'--add Microsoft.VisualStudio.Component.VC.ATL.ARM ' + `
'--add Microsoft.VisualStudio.Component.VC.ATL.ARM.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.ATL.ARM64 ' + `
'--add Microsoft.VisualStudio.Component.VC.ATL.ARM64.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.ATL.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.ATLMFC ' + `
'--add Microsoft.VisualStudio.Component.VC.ATLMFC.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.CLI.Support ' + `
'--add Microsoft.VisualStudio.Component.VC.CMake.Project ' + `
'--add Microsoft.VisualStudio.Component.VC.CoreIde ' + `
'--add Microsoft.VisualStudio.Component.VC.DiagnosticTools ' + `
'--add Microsoft.VisualStudio.Component.VC.Llvm.Clang ' + `
'--add Microsoft.VisualStudio.Component.VC.Llvm.ClangToolset ' + `
'--add Microsoft.VisualStudio.Component.VC.MFC.ARM ' + `
'--add Microsoft.VisualStudio.Component.VC.MFC.ARM.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.MFC.ARM64 ' + `
'--add Microsoft.VisualStudio.Component.VC.MFC.ARM64.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.Redist.14.Latest ' + `
'--add Microsoft.VisualStudio.Component.VC.Redist.MSM ' + `
'--add Microsoft.VisualStudio.Component.VC.Runtimes.ARM.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.Runtimes.ARM64.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.Runtimes.x86.x64.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.TestAdapterForBoostTest ' + `
'--add Microsoft.VisualStudio.Component.VC.TestAdapterForGoogleTest ' + `
'--add Microsoft.VisualStudio.Component.VC.Tools.ARM ' + `
'--add Microsoft.VisualStudio.Component.VC.Tools.ARM64 ' + `
'--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 ' + `
'--add Microsoft.VisualStudio.Component.VC.v141.ARM ' + `
'--add Microsoft.VisualStudio.Component.VC.v141.ARM.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.v141.ARM64 ' + `
'--add Microsoft.VisualStudio.Component.VC.v141.ARM64.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.v141.ATL ' + `
'--add Microsoft.VisualStudio.Component.VC.v141.ATL.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.v141.CLI.Support ' + `
'--add Microsoft.VisualStudio.Component.VC.v141.MFC ' + `
'--add Microsoft.VisualStudio.Component.VC.v141.MFC.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VC.v141.x86.x64 ' + `
'--add Microsoft.VisualStudio.Component.VC.v141.x86.x64.Spectre ' + `
'--add Microsoft.VisualStudio.Component.VSSDK ' + `
'--add Microsoft.VisualStudio.Component.Wcf.Tooling ' + `
'--add Microsoft.VisualStudio.Component.Web ' + `
'--add Microsoft.VisualStudio.Component.WebDeploy ' + `
'--add Microsoft.VisualStudio.Component.Windows10SDK.16299 ' + `
'--add Microsoft.VisualStudio.Component.Windows10SDK.17134 ' + `
'--add Microsoft.VisualStudio.Component.Windows10SDK.17763 ' + `
'--add Microsoft.VisualStudio.Component.Windows10SDK.18362 ' + `
'--add Microsoft.VisualStudio.Component.Windows10SDK.19041 ' + `
'--add Microsoft.VisualStudio.Component.WinXP ' + `
'--add Microsoft.VisualStudio.Component.Workflow ' + `
'--add Microsoft.VisualStudio.ComponentGroup.Azure.CloudServices ' + `
'--add Microsoft.VisualStudio.ComponentGroup.Azure.Prerequisites ' + `
'--add Microsoft.VisualStudio.ComponentGroup.Azure.ResourceManager.Tools ' + `
'--add Microsoft.VisualStudio.ComponentGroup.AzureFunctions ' + `
'--add Microsoft.VisualStudio.ComponentGroup.MSIX.Packaging ' + `
'--add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core ' + `
'--add Microsoft.VisualStudio.ComponentGroup.UWP.NetCoreAndStandard ' + `
'--add Microsoft.VisualStudio.ComponentGroup.UWP.Support ' + `
'--add Microsoft.VisualStudio.ComponentGroup.UWP.Xamarin ' + `
'--add Microsoft.VisualStudio.ComponentGroup.UWP.VC ' + `
'--add Microsoft.VisualStudio.ComponentGroup.UWP.VC.v141 ' + `
'--add Microsoft.VisualStudio.ComponentGroup.VisualStudioExtension.Prerequisites ' + `
'--add Microsoft.VisualStudio.ComponentGroup.Web ' + `
'--add Microsoft.VisualStudio.ComponentGroup.Web.CloudTools ' + `
'--add Microsoft.VisualStudio.ComponentGroup.WebToolsExtensions ' + `
'--add Microsoft.VisualStudio.ComponentGroup.WebToolsExtensions.CMake ' + `
'--add Microsoft.VisualStudio.ComponentGroup.WebToolsExtensions.TemplateEngine ' + `
'--add Microsoft.VisualStudio.Workload.Azure ' + `
'--add Microsoft.VisualStudio.Workload.CoreEditor ' + `
'--add Microsoft.VisualStudio.Workload.Data ' + `
'--add Microsoft.VisualStudio.Workload.ManagedDesktop ' + `
'--add Microsoft.VisualStudio.Workload.NativeDesktop ' + `
'--add Microsoft.VisualStudio.Workload.NativeMobile ' + `
'--add Microsoft.VisualStudio.Workload.NetCoreTools ' + `
'--add Microsoft.VisualStudio.Workload.NetCrossPlat ' + `
'--add Microsoft.VisualStudio.Workload.NetWeb ' + `
'--add Microsoft.VisualStudio.Workload.Office ' + `
'--add Microsoft.VisualStudio.Workload.Universal ' + `
'--add Microsoft.VisualStudio.Workload.VisualStudioExtension '
$Sku = 'Community'
$ChannelUri = $null
if ($env:install_vs2019_preview) {
Write-Host "Installing from 'Preview' channel"
$VSBootstrapperURL = 'https://aka.ms/vs/16/pre/vs_community.exe'
} else {
Write-Host "Installing from 'Release' channel"
$VSBootstrapperURL = 'https://aka.ms/vs/16/release/vs_community.exe'
# This is how to know channelUri for previous versions of VS 2019
# - Download previous bootstrapper for Professional edition: https://docs.microsoft.com/en-us/visualstudio/releases/2019/history#release-dates-and-build-numbers
# - Run `.\vs_Professional.exe --layout .\VSLayout
# - In the output log look for the first line with `/channel`, for example:
#
# Download of 'https://aka.ms/vs/16/release/149189645_1152370582/channel' succeeded using engine 'WebClient'
# https://aka.ms/vs/16/release/149189645_1152370582/channel is the url to `VisualStudio.16.Release.chman` file.
# Pin VS 2019 16.5.5 for now because of issues with devenv.com: https://developercommunity.visualstudio.com/content/problem/1048804/cannot-build-project-with-devenvcom-in-visual-stud.html
#$ChannelUri = 'https://aka.ms/vs/16/release/149189645_1152370582/channel'
#$VSBootstrapperURL = 'https://download.visualstudio.microsoft.com/download/pr/68d6b204-9df0-4fcc-abcc-08ee0eff9cb2/b029547488a9383b0c8d8a9c813e246feb3ec19e0fe55020d4878fde5f0983fe/vs_Community.exe'
}
$ErrorActionPreference = 'Stop'
# Install VS
$exitCode = InstallVS -WorkLoads $WorkLoads -Sku $Sku -VSBootstrapperURL $VSBootstrapperURL -ChannelUri $ChannelUri
$vsPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\Community"
if (-not (Test-Path $vsPath)) {
$vsPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\Preview"
}
Write-Host "Initializing Visual Studio Experimental Instance"
& "$vsPath\Common7\IDE\devenv.exe" /RootSuffix Exp /ResetSettings General.vssettings /Command File.Exit
Write-Host "Disabling VS-related services"
if (get-Service SQLWriterw -ErrorAction Ignore) {
Stop-Service SQLWriter
Set-Service SQLWriter -StartupType Manual
}
if (get-Service IpOverUsbSvc -ErrorAction Ignore) {
Stop-Service IpOverUsbSvc
Set-Service IpOverUsbSvc -StartupType Manual
}
Write-Host "Adding Visual Studio 2019 current MSBuild to PATH..." -ForegroundColor Cyan
Add-Path "$vsPath\MSBuild\Current\Bin"
Add-Path "$vsPath\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\150"
Write-Host "Warm up default .NET Core SDK"
$projectPath = "$env:temp\TestCoreApp"
New-Item -Path $projectPath -Force -ItemType Directory | Out-Null
Push-Location -Path $projectPath
& $env:ProgramFiles\dotnet\dotnet.exe new console
Pop-Location
Remove-Item $projectPath -Force -Recurse