-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
41 lines (32 loc) · 1.28 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
[cmdletbinding()]
param (
[Parameter(Position = 0)]
[ValidateSet("Test", "Docs", "Publish", "PublishDocs")]
[string]$Task,
[string[]]$PowerShellModules = @('Pester', 'PSScriptAnalyzer', 'InvokeBuild', 'BuildHelpers', 'platyPS'),
[string[]]$PackageProviders = @('NuGet', 'PowerShellGet')
)
Set-StrictMode -Version 1.0
# Install package providers for PowerShell Modules
foreach ($provider in $PackageProviders) {
if (-not (Get-PackageProvider -Name $provider -ErrorAction SilentlyContinue)) {
Install-PackageProvider -Name $provider -Force -ForceBootstrap -Scope CurrentUser
}
}
# Install the PowerShell Modules
foreach ($module in $PowerShellModules) {
if (-not (Get-Module -ListAvailable $module -ErrorAction SilentlyContinue)) {
Install-Module $Module -Scope CurrentUser -Force -Repository 'PSGallery'
}
Import-Module $Module -Force
}
Push-Location $PSScriptRoot
Get-ChildItem -Path ENV:\BH* | Remove-Item
Set-BuildEnvironment
Import-Module -Name "$Env:BHProjectPath\Build\build.psm1" -Global -ErrorAction Stop
Invoke-Build -Task $Task -Result 'InvokeBuildResult' -File "$Env:BHProjectPath\Build\NexthinkPSUtils.build.ps1"
Remove-Item -Path Env:\BH*
if ($InvokeBuildResult.Error) {
$Error[-1].ScriptStackTrace | Out-String
exit 1
}