-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathbuild.ps1
More file actions
79 lines (67 loc) · 2.38 KB
/
Copy pathbuild.ps1
File metadata and controls
79 lines (67 loc) · 2.38 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
#Requires -Version 7.0
<#
.SYNOPSIS
Bootstrap script for IntuneHydrationKit build process
.DESCRIPTION
Installs required build dependencies (InvokeBuild, Pester, PSScriptAnalyzer)
and optionally invokes the build process.
.PARAMETER Task
The build task(s) to run. If not specified, runs the default validation task.
.PARAMETER NoBuild
Only install dependencies, don't run any build tasks.
.EXAMPLE
./build.ps1
Installs dependencies and runs the default validation task.
.EXAMPLE
./build.ps1 -Task Build
Installs dependencies and runs the Build task.
.EXAMPLE
./build.ps1 -Task Analyze, Test, Build
Installs dependencies and runs multiple tasks.
#>
[CmdletBinding()]
param(
[Parameter()]
[string[]]$Task,
[Parameter()]
[switch]$NoBuild
)
$ErrorActionPreference = 'Stop'
$InformationPreference = 'Continue'
Write-Information "=== IntuneHydrationKit Build Bootstrap ==="
# Required modules for build process
$requiredModules = @(
@{ Name = 'InvokeBuild'; MinimumVersion = '5.10.0' }
@{ Name = 'Pester'; MinimumVersion = '5.4.0' }
@{ Name = 'PSScriptAnalyzer'; MinimumVersion = '1.21.0' }
@{ Name = 'Microsoft.Graph.Authentication'; MinimumVersion = '2.0.0' }
)
# Install/update required modules
foreach ($module in $requiredModules) {
$installed = Get-Module -Name $module.Name -ListAvailable |
Where-Object { $_.Version -ge [version]$module.MinimumVersion } |
Sort-Object Version -Descending |
Select-Object -First 1
if (-not $installed) {
Write-Information "Installing $($module.Name) >= $($module.MinimumVersion)..."
Install-Module -Name $module.Name -MinimumVersion $module.MinimumVersion -Force -Scope CurrentUser -AllowClobber
Write-Information " Installed $($module.Name)"
} else {
Write-Information "Found $($module.Name) v$($installed.Version)"
}
}
Write-Information "Bootstrap complete."
# Run build unless explicitly disabled
if (-not $NoBuild) {
if (-not $Task) {
$Task = @('.')
}
Write-Information ""
Write-Information "Running build tasks: $($Task -join ', ')"
$buildScript = Join-Path -Path $PSScriptRoot -ChildPath 'IntuneHydrationKit.build.ps1'
if (-not (Test-Path $buildScript)) {
throw "Build script not found: $buildScript"
}
Import-Module InvokeBuild -Force
Invoke-Build -File $buildScript -Task $Task
}