forked from react-native-webview/react-native-webview
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall-vs-features.ps1
More file actions
108 lines (82 loc) · 2.8 KB
/
Copy pathinstall-vs-features.ps1
File metadata and controls
108 lines (82 loc) · 2.8 KB
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
param (
[Parameter(Mandatory=$true)]
[string[]] $Components,
[uri] $InstallerUri = "https://download.visualstudio.microsoft.com/download/pr/c4fef23e-cc45-4836-9544-70e213134bc8/1ee5717e9a1e05015756dff77eb27d554a79a6db91f2716d836df368381af9a1/vs_Enterprise.exe",
[string] $VsInstaller = "${env:System_DefaultWorkingDirectory}\vs_Enterprise.exe",
[string] $VsInstallOutputDir = "${env:System_DefaultWorkingDirectory}\vs",
[System.IO.FileInfo] $VsInstallPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\Enterprise",
[System.IO.FileInfo] $VsInstallerPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer",
[switch] $Collect = $false,
[switch] $Cleanup = $false,
[switch] $UseWebInstaller = $false
)
$Components | ForEach-Object {
$componentList += '--add', $_
}
$LocalVsInstaller = "$VsInstallerPath\vs_installershell.exe"
$UseWebInstaller = $UseWebInstaller -or -not (Test-Path -Path "$LocalVsInstaller")
if ($UseWebInstaller) {
Write-Host "Downloading web installer..."
Invoke-WebRequest -Method Get `
-Uri $InstallerUri `
-OutFile $VsInstaller
New-Item -ItemType directory -Path $VsInstallOutputDir
Write-Host "Running web installer to download requested components..."
Start-Process `
-FilePath "$VsInstaller" `
-ArgumentList ( `
'--layout', "$VsInstallOutputDir",
'--wait',
'--norestart',
'--quiet' + `
$componentList
) `
-Wait `
-PassThru
Write-Host "Running downloaded VS installer to add requested components..."
Start-Process `
-FilePath "$VsInstallOutputDir\vs_Enterprise.exe" `
-ArgumentList (
'modify',
'--installPath', "`"$VsInstallPath`"" ,
'--wait',
'--norestart',
'--quiet' + `
$componentList
) `
-Wait `
-PassThru `
-OutVariable returnCode
if ($Cleanup) {
Write-Host "Cleaning up..."
Remove-Item -Path $VsInstaller
Remove-Item -Path $VsInstallOutputDir -Recurse
}
} else {
Write-Host "Running local installer to add requested components..."
Start-Process `
-FilePath "$LocalVsInstaller" `
-ArgumentList (
'modify',
'--installPath', "`"$VsInstallPath`"" ,
'--norestart',
'--quiet' + `
$componentList
) `
-Wait `
-OutVariable returnCode
}
if ($Collect) {
Invoke-WebRequest -Method Get `
-Uri 'https://download.microsoft.com/download/8/3/4/834E83F6-C377-4DCE-A757-69A418B6C6DF/Collect.exe' `
-OutFile ${env:System_DefaultWorkingDirectory}\Collect.exe
# Should generate ${env:Temp}\vslogs.zip
Start-Process `
-FilePath "${env:System_DefaultWorkingDirectory}\Collect.exe" `
-Wait `
-PassThru
New-Item -ItemType Directory -Force ${env:System_DefaultWorkingDirectory}\vslogs
Expand-Archive -Path ${env:TEMP}\vslogs.zip -DestinationPath ${env:System_DefaultWorkingDirectory}\vslogs\
Write-Host "VC versions after installation:"
Get-ChildItem -Name "$VsInstallPath\VC\Tools\MSVC\"
}