-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
97 lines (80 loc) · 3.45 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
94
95
96
97
#Requires -Version 7.2
$Output = "$PSScriptRoot\output"
$obj = "$PSScriptRoot\obj"
$Version = (Get-Content $PSScriptRoot\version.txt)
Remove-Item $Output -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item $obj -Recurse -Force -ErrorAction SilentlyContinue
$Modules = @(
@{Name = 'Microsoft.PowerShell.Crescendo'; Version = '1.1.0'}
@{Name = 'Pester'; Version = '4.10.1'}
@{Name = 'PSScriptAnalyzer'; Version = '1.21.0'}
)
foreach ($Module in $Modules) {
$ModuleExist = Import-Module `
-Name $Module.Name `
-RequiredVersion $Module.Version `
-PassThru `
-ErrorAction SilentlyContinue
if (-not $ModuleExist) {
Install-Module $Module.Name -RequiredVersion $Module.Version -AllowPrerelease -Force -Scope CurrentUser
}
}
New-Item $Output -ItemType Directory
New-Item $obj -ItemType Directory
if (-not (Get-Item function:Invoke-ParseError)) {
throw 'Missing functions'
}
<#
$Commands = Get-ChildItem "$PSScriptRoot\src\*.json" | foreach {
$Definition = Get-Content $_.FullName | ConvertFrom-Json | Select -ExpandProperty Commands
$Command = New-CrescendoCommand -Verb $Definition.Verb -Noun $Definition.Noun -OriginalName $Definition.OriginalName
$Command.OriginalCommandElements = $Definition.OriginalCommandElements
$Command.Platform = "Windows"
if ($Definition.Parameters) {
$Command.Parameters = $Definition.Parameters | ForEach-Object {
$Parameter = New-ParameterInfo -Name $_.Name -OriginalName $_.OriginalName
$Parameter.OriginalName = $_.OriginalName
$Parameter.OriginalPosition = $_.OriginalPosition
$Parameter.ParameterType = $_.ParameterType
$Parameter
}
}
if ($Definition.OutputHandlers) {
$Command.OutputHandlers = $Definition.OutputHandlers | ForEach-Object {
$Handler = New-OutputHandler
$Handler.ParameterSetName = $_.ParameterSetName
$Handler.Handler = $_.Handler
$Handler.HandlerType = $_.HandlerType
$Handler.StreamOutput = $_.StreamOutput
$Handler
}
}
$Command
}
@{
'$schema' = 'https://aka.ms/PowerShell/Crescendo/Schemas/2022-06'
Commands = $Commands
} | ConvertTo-Json -Depth 5 | Out-File "$obj\Commands.json"
Export-CrescendoModule -ConfigurationFile (Get-ChildItem "$obj\*.json") -ModuleName (Join-Path $Output 'PSConfig.Crescendo') -Force
#>
Export-CrescendoModule `
-ConfigurationFile $PSScriptRoot\src\PSConfig.Crescendo.json `
-ModuleName (Join-Path $Output 'PSConfig.Crescendo') `
-Force
$ManifestInfo = @{
ModuleVersion = $Version
Author = 'Dennis Lindvist'
Company = '-'
Copyright = 'Dennis Lindqvist'
Description = 'PowerShell cmdlets for SharePoint PSConfig tool wrapped with MS Crescendo.'
LicenseUri = 'https://github.com/DennisL68/PSConfig.Crescendo/blob/main/LICENSE'
ProjectUri = 'https://github.com/DennisL68/PSConfig.Crescendo'
Tags = @('SharePoint','PSConfig','CrescendoBuilt','SharePoint-On-Prem','SharePoint-Product-Configuration-Wizard')
#A URL to an icon representing this module.
#IconUri = ''
#ReleaseNotes of this module
#ReleaseNotes = ''
}
Update-ModuleManifest -Path (Join-Path $Output 'PSConfig.Crescendo.psd1') @ManifestInfo
Invoke-ScriptAnalyzer "$PSScriptRoot\output\PSConfig.Crescendo.psd1" -ExcludeRule PSAvoidTrailingWhitespace
Invoke-Pester -Path "$PSScriptRoot\tests"