-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathbuild.ps1
More file actions
75 lines (64 loc) · 2.31 KB
/
build.ps1
File metadata and controls
75 lines (64 loc) · 2.31 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
#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, only bootstraps dependencies.
.PARAMETER NoBuild
Only install dependencies, don't run any build tasks.
.EXAMPLE
./build.ps1
Installs dependencies only.
.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 if tasks specified and not NoBuild
if ($Task -and -not $NoBuild) {
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
}