-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.ps1
69 lines (59 loc) · 2.04 KB
/
init.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
param (
[Parameter(Mandatory = $false)]
[Boolean]$VsPreview=$true
)
Function Get-MsBuildPath($useVsPreview) {
if (-not (Test-Path "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"))
{
Throw "Unable to find 'vswhere.exe'. Is Visual Studio installed?"
}
$path = ""
try {
if ($useVsPreview)
{
$path = & "${env:ProgramFiles(x86)}\microsoft visual studio\installer\vswhere.exe" -latest -prerelease -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe | select-object -first 1
}
else
{
$path = & "${env:ProgramFiles(x86)}\microsoft visual studio\installer\vswhere.exe" -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe | select-object -first 1
}
}
catch {
}
if (!$path)
{
Write-Error "Unable to find MSBuild. Try importing './.vsconfig' into Visual Studio Installer."
}
return $path
}
Function Restore-PackagesUnder($searchRoot) {
# Restore VS solution dependencies
Get-ChildItem $searchRoot -rec |? { $_.FullName.EndsWith('.sln') } |% {
Write-Host "Restoring packages for $($_.FullName)..." -ForegroundColor $HeaderColor
& "$toolsPath\Restore-NuGetPackages.ps1" -Path $_.FullName -Verbosity $nugetVerbosity -MSBuildPath $MSBuildPath
}
}
Function Restore-MonacoEditor() {
# Restore Monaco Editor
Write-Host "Restoring Monaco Editor..." -ForegroundColor $HeaderColor
& "$toolsPath\Restore-MonacoEditor.ps1"
}
Push-Location $PSScriptRoot
try {
$EnvVarsSet = $false
$HeaderColor = 'Green'
$toolsPath = "$PSScriptRoot\tools"
$nugetVerbosity = 'minimal'
$MSBuildPath = Get-MsBuildPath $VsPreview
if ($VerbosePreference -eq 'continue') { $nugetVerbosity = 'Detailed' }
Restore-PackagesUnder "$PSScriptRoot\src"
Restore-MonacoEditor
Write-Host "Successfully restored all dependencies" -ForegroundColor Yellow
}
catch {
Write-Error $error[0]
exit $lastexitcode
}
finally {
Pop-Location
}