This repository has been archived by the owner on Jun 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
build.ps1
93 lines (79 loc) · 2.01 KB
/
build.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
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#!/usr/bin/env pwsh
param(
[Parameter()]
[switch]
$Bootstrap,
[Parameter()]
[switch]
$Clean,
[Parameter()]
[switch]
$Test
)
$NeededTools = @{
PowerShellCore = "PowerShell Core 6.0.0 or greater"
DotNetSdk = "dotnet sdk 2.0 or greater"
InvokeBuild = "InvokeBuild latest"
}
function needsPowerShellCore () {
try {
$powershellverison = (pwsh -v)
} catch {
return $true
}
return $false
}
function needsDotNetSdk () {
try {
$dotnetverison = (dotnet --version)
} catch {
return $true
}
return $false
}
function needsInvokeBuild () {
if (Get-Module -ListAvailable -Name InvokeBuild) {
return $false
}
return $true
}
function getMissingTools () {
$missingTools = @()
if (needsPowerShellCore) {
$missingTools += $NeededTools.PowerShellCore
}
if (needsDotNetSdk) {
$missingTools += $NeededTools.DotNetSdk
}
if (needsInvokeBuild) {
$missingTools += $NeededTools.InvokeBuild
}
return $missingTools
}
function hasMissingTools () {
return ((getMissingTools).Count -gt 0)
}
if ($Bootstrap) {
$string = "Here is what your environment is missing:`n"
$missingTools = getMissingTools
if (($missingTools).Count -eq 0) {
$string += "* nothing!`n`n Run this script without a flag to build or a -Clean to clean."
} else {
$missingTools | ForEach-Object {$string += "* $_`n"}
$string += "`nAll instructions for installing these tools can be found on PowerShell Editor Services' Github:`n" `
+ "https://github.com/powershell/PowerShellEditorServices#development"
}
Write-Host "`n$string`n"
} elseif(hasMissingTools) {
Write-Host "You are missing needed tools. Run './build.ps1 -Bootstrap' to see what they are."
} else {
if($Clean) {
Invoke-Build Clean
}
Invoke-Build Package
if($Test) {
Invoke-Build Test
}
}