Skip to content

Commit abd30f9

Browse files
chore: ✏️ New task dependencies (#85)
- Added new task dependencies in `psakeFile.ps1` to improve build process. - Updated `CHANGELOG.md` to reflect changes in task dependencies. - Enhanced `README.md` with detailed descriptions of task dependencies and their default values.
1 parent 51be9ec commit abd30f9

File tree

4 files changed

+164
-127
lines changed

4 files changed

+164
-127
lines changed

CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## Unreleased
9+
10+
- Add new dependencies variables to allow end user to modify which tasks are
11+
run.
12+
813
## [0.7.2] 2025-05-21
914

1015
### Added
1116

12-
- The `$PSBPreference` variable now supports the following PlatyPS `New-MarkdownHelp` and `Update-MarkdownHelp` boolean
13-
options:
17+
- The `$PSBPreference` variable now supports the following PlatyPS
18+
`New-MarkdownHelp` and `Update-MarkdownHelp` boolean options:
1419
- `$PSBPreference.Docs.AlphabeticParamsOrder`
1520
- `$PSBPreference.Docs.ExcludeDontShow`
1621
- `$PSBPreference.Docs.UseFullTypeName`

PowerShellBuild/build.properties.ps1

Lines changed: 35 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -7,63 +7,63 @@ $moduleVersion = (Import-PowerShellDataFile -Path $env:BHPSModuleManifest).Modul
77
[ordered]@{
88
General = @{
99
# Root directory for the project
10-
ProjectRoot = $env:BHProjectPath
10+
ProjectRoot = $env:BHProjectPath
1111

1212
# Root directory for the module
13-
SrcRootDir = $env:BHPSModulePath
13+
SrcRootDir = $env:BHPSModulePath
1414

1515
# The name of the module. This should match the basename of the PSD1 file
16-
ModuleName = $env:BHProjectName
16+
ModuleName = $env:BHProjectName
1717

1818
# Module version
19-
ModuleVersion = $moduleVersion
19+
ModuleVersion = $moduleVersion
2020

2121
# Module manifest path
2222
ModuleManifestPath = $env:BHPSModuleManifest
2323
}
24-
Build = @{
24+
Build = @{
2525

2626
# "Dependencies" moved to TaskDependencies section
2727

2828
# Output directory when building a module
29-
OutDir = $outDir
29+
OutDir = $outDir
3030

3131
# Module output directory
3232
# This will be computed in 'Initialize-PSBuild' so we can allow the user to
3333
# override the top-level 'OutDir' above and compute the full path to the module internally
34-
ModuleOutDir = $null
34+
ModuleOutDir = $null
3535

3636
# Controls whether to "compile" module into single PSM1 or not
37-
CompileModule = $false
37+
CompileModule = $false
3838

3939
# List of directories that if CompileModule is $true, will be concatenated into the PSM1
4040
CompileDirectories = @('Enum', 'Classes', 'Private', 'Public')
4141

4242
# List of directories that will always be copied "as is" to output directory
43-
CopyDirectories = @()
43+
CopyDirectories = @()
4444

4545
# List of files (regular expressions) to exclude from output directory
46-
Exclude = @()
46+
Exclude = @()
4747
}
48-
Test = @{
48+
Test = @{
4949
# Enable/disable Pester tests
50-
Enabled = $true
50+
Enabled = $true
5151

5252
# Directory containing Pester tests
53-
RootDir = [IO.Path]::Combine($env:BHProjectPath, 'tests')
53+
RootDir = [IO.Path]::Combine($env:BHProjectPath, 'tests')
5454

5555
# Specifies an output file path to send to Invoke-Pester's -OutputFile parameter.
5656
# This is typically used to write out test results so that they can be sent to a CI system
5757
# This path is relative to the directory containing Pester tests
58-
OutputFile = [IO.Path]::Combine($env:BHProjectPath, 'testResults.xml')
58+
OutputFile = [IO.Path]::Combine($env:BHProjectPath, 'testResults.xml')
5959

6060
# Specifies the test output format to use when the TestOutputFile property is given
6161
# a path. This parameter is passed through to Invoke-Pester's -OutputFormat parameter.
62-
OutputFormat = 'NUnitXml'
62+
OutputFormat = 'NUnitXml'
6363

64-
ScriptAnalysis = @{
64+
ScriptAnalysis = @{
6565
# Enable/disable use of PSScriptAnalyzer to perform script analysis
66-
Enabled = $true
66+
Enabled = $true
6767

6868
# When PSScriptAnalyzer is enabled, control which severity level will generate a build failure.
6969
# Valid values are Error, Warning, Information and None. "None" will report errors but will not
@@ -73,26 +73,26 @@ $moduleVersion = (Import-PowerShellDataFile -Path $env:BHPSModuleManifest).Modul
7373
FailBuildOnSeverityLevel = 'Error'
7474

7575
# Path to the PSScriptAnalyzer settings file.
76-
SettingsPath = [IO.Path]::Combine($PSScriptRoot, 'ScriptAnalyzerSettings.psd1')
76+
SettingsPath = [IO.Path]::Combine($PSScriptRoot, 'ScriptAnalyzerSettings.psd1')
7777
}
7878

7979
# Import module from OutDir prior to running Pester tests.
80-
ImportModule = $false
80+
ImportModule = $false
8181

82-
CodeCoverage = @{
82+
CodeCoverage = @{
8383
# Enable/disable Pester code coverage reporting.
84-
Enabled = $false
84+
Enabled = $false
8585

8686
# Fail Pester code coverage test if below this threshold
87-
Threshold = .75
87+
Threshold = .75
8888

8989
# CodeCoverageFiles specifies the files to perform code coverage analysis on. This property
9090
# acts as a direct input to the Pester -CodeCoverage parameter, so will support constructions
9191
# like the ones found here: https://pester.dev/docs/usage/code-coverage.
92-
Files = @()
92+
Files = @()
9393

9494
# Path to write code coverage report to
95-
OutputFile = [IO.Path]::Combine($env:BHProjectPath, 'codeCoverage.xml')
95+
OutputFile = [IO.Path]::Combine($env:BHProjectPath, 'codeCoverage.xml')
9696

9797
# The code coverage output format to use
9898
OutputFileFormat = 'JaCoCo'
@@ -102,61 +102,48 @@ $moduleVersion = (Import-PowerShellDataFile -Path $env:BHPSModuleManifest).Modul
102102
SkipRemainingOnFailure = 'None'
103103

104104
# Set verbosity of output. Options are None, Normal, Detailed and Diagnostic. Default: Detailed.
105-
OutputVerbosity = 'Detailed'
105+
OutputVerbosity = 'Detailed'
106106
}
107-
Help = @{
107+
Help = @{
108108
# Path to updatable help CAB
109-
UpdatableHelpOutDir = [IO.Path]::Combine($outDir, 'UpdatableHelp')
109+
UpdatableHelpOutDir = [IO.Path]::Combine($outDir, 'UpdatableHelp')
110110

111111
# Default Locale used for help generation, defaults to en-US
112112
# Get-UICulture doesn't return a name on Linux so default to en-US
113-
DefaultLocale = if (-not (Get-UICulture).Name) { 'en-US' } else { (Get-UICulture).Name }
113+
DefaultLocale = if (-not (Get-UICulture).Name) { 'en-US' } else { (Get-UICulture).Name }
114114

115115
# Convert project readme into the module about file
116116
ConvertReadMeToAboutHelp = $false
117117
}
118-
Docs = @{
118+
Docs = @{
119119
# Directory PlatyPS markdown documentation will be saved to
120-
RootDir = [IO.Path]::Combine($env:BHProjectPath, 'docs')
120+
RootDir = [IO.Path]::Combine($env:BHProjectPath, 'docs')
121121

122122
# Whether to overwrite existing markdown files and use comment based help as the source of truth
123-
Overwrite = $false
123+
Overwrite = $false
124124

125125
# Whether to order parameters alphabetically by name in PARAMETERS section.
126126
# Value passed to New-MarkdownHelp and Update-MarkdownHelp.
127127
AlphabeticParamsOrder = $false
128128

129129
# Exclude the parameters marked with `DontShow` in the parameter attribute from the help content.
130130
# Value passed to New-MarkdownHelp and Update-MarkdownHelp.
131-
ExcludeDontShow = $false
131+
ExcludeDontShow = $false
132132

133133
# Indicates that the target document will use a full type name instead of a short name for parameters.
134134
# Value passed to New-MarkdownHelp and Update-MarkdownHelp.
135-
UseFullTypeName = $false
135+
UseFullTypeName = $false
136136
}
137137
Publish = @{
138138
# PowerShell repository name to publish modules to
139-
PSRepository = 'PSGallery'
139+
PSRepository = 'PSGallery'
140140

141141
# API key to authenticate to PowerShell repository with
142-
PSRepositoryApiKey = $env:PSGALLERY_API_KEY
142+
PSRepositoryApiKey = $env:PSGALLERY_API_KEY
143143

144144
# Credential to authenticate to PowerShell repository with
145145
PSRepositoryCredential = $null
146146
}
147-
TaskDependencies = @{
148-
Clean = @('Init')
149-
StageFiles = @('Clean')
150-
Build = @('StageFiles', 'BuildHelp')
151-
Analyze = @('Build')
152-
Pester = @('Build')
153-
Test = @('Pester', 'Analyze')
154-
BuildHelp = @('GenerateMarkdown', 'GenerateMAML')
155-
GenerateMarkdown = @('StageFiles')
156-
GenerateMAML = @('GenerateMarkdown')
157-
GenerateUpdatableHelp = @('BuildHelp')
158-
Publish = @('Test')
159-
}
160147
}
161148

162149
# Enable/disable generation of a catalog (.cat) file for the module.

PowerShellBuild/psakeFile.ps1

Lines changed: 59 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,55 @@ FormatTaskName {
1111
Write-Host $taskName.ToUpper() -ForegroundColor Blue
1212
}
1313

14+
#region Task Dependencies
15+
if ($null -eq $PSBCleanDependency) {
16+
$PSBCleanDependency = @('Init')
17+
}
18+
if ($null -eq $PSBStageFilesDependency) {
19+
$PSBStageFilesDependency = @('Clean')
20+
}
21+
if ($null -eq $PSBBuildDependency) {
22+
$PSBBuildDependency = @('StageFiles', 'BuildHelp')
23+
}
24+
if ($null -eq $PSBAnalyzeDependency) {
25+
$PSBAnalyzeDependency = @('Build')
26+
}
27+
if ($null -eq $PSBPesterDependency) {
28+
$PSBPesterDependency = @('Build')
29+
}
30+
if ($null -eq $PSBTestDependency) {
31+
$PSBTestDependency = @('Pester', 'Analyze')
32+
}
33+
if ($null -eq $PSBBuildHelpDependency) {
34+
$PSBBuildHelpDependency = @('GenerateMarkdown', 'GenerateMAML')
35+
}
36+
if ($null -eq $PSBGenerateMarkdownDependency) {
37+
$PSBGenerateMarkdownDependency = @('StageFiles')
38+
}
39+
if ($null -eq $PSBGenerateMAMLDependency) {
40+
$PSBGenerateMAMLDependency = @('GenerateMarkdown')
41+
}
42+
if ($null -eq $PSBGenerateUpdatableHelpDependency) {
43+
$PSBGenerateUpdatableHelpDependency = @('BuildHelp')
44+
}
45+
if ($null -eq $PSBPublishDependency) {
46+
$PSBPublishDependency = @('Test')
47+
}
48+
#endregion Task Dependencies
49+
1450
# This psake file is meant to be referenced from another
1551
# Can't have two 'default' tasks
1652
# Task default -depends Test
1753

1854
Task Init {
1955
Initialize-PSBuild -UseBuildHelpers -BuildEnvironment $PSBPreference
20-
} -description 'Initialize build environment variables'
56+
} -Description 'Initialize build environment variables'
2157

22-
Task Clean -depends $PSBPreference.TaskDependencies.Clean {
58+
Task Clean -Depends $PSBCleanDependency {
2359
Clear-PSBuildOutputFolder -Path $PSBPreference.Build.ModuleOutDir
24-
} -description 'Clears module output directory'
60+
} -Description 'Clears module output directory'
2561

26-
Task StageFiles -depends $PSBPreference.TaskDependencies.StageFiles {
62+
Task StageFiles -Depends $PSBStageFilesDependency {
2763
$buildParams = @{
2864
Path = $PSBPreference.General.SrcRootDir
2965
ModuleName = $PSBPreference.General.ModuleName
@@ -51,9 +87,9 @@ Task StageFiles -depends $PSBPreference.TaskDependencies.StageFiles {
5187
}
5288

5389
Build-PSBuildModule @buildParams
54-
} -description 'Builds module based on source directory'
90+
} -Description 'Builds module based on source directory'
5591

56-
Task Build -depends $PSBPreference.TaskDependencies.Build -description 'Builds module and generate help documentation'
92+
Task Build -Depends $PSBBuildDependency -Description 'Builds module and generate help documentation'
5793

5894
$analyzePreReqs = {
5995
$result = $true
@@ -67,14 +103,14 @@ $analyzePreReqs = {
67103
}
68104
$result
69105
}
70-
Task Analyze -depends $PSBPreference.TaskDependencies.Analyze -precondition $analyzePreReqs {
106+
Task Analyze -Depends $PSBAnalyzeDependency -PreCondition $analyzePreReqs {
71107
$analyzeParams = @{
72108
Path = $PSBPreference.Build.ModuleOutDir
73109
SeverityThreshold = $PSBPreference.Test.ScriptAnalysis.FailBuildOnSeverityLevel
74110
SettingsPath = $PSBPreference.Test.ScriptAnalysis.SettingsPath
75111
}
76112
Test-PSBuildScriptAnalysis @analyzeParams
77-
} -description 'Execute PSScriptAnalyzer tests'
113+
} -Description 'Execute PSScriptAnalyzer tests'
78114

79115
$pesterPreReqs = {
80116
$result = $true
@@ -92,7 +128,7 @@ $pesterPreReqs = {
92128
}
93129
return $result
94130
}
95-
Task Pester -depends $PSBPreference.TaskDependencies.Pester -precondition $pesterPreReqs {
131+
Task Pester -Depends $PSBPesterDependency -PreCondition $pesterPreReqs {
96132
$pesterParams = @{
97133
Path = $PSBPreference.Test.RootDir
98134
ModuleName = $PSBPreference.General.ModuleName
@@ -109,12 +145,12 @@ Task Pester -depends $PSBPreference.TaskDependencies.Pester -precondition $peste
109145
OutputVerbosity = $PSBPreference.Test.OutputVerbosity
110146
}
111147
Test-PSBuildPester @pesterParams
112-
} -description 'Execute Pester tests'
148+
} -Description 'Execute Pester tests'
113149

114-
Task Test -depends $PSBPreference.TaskDependencies.Test {
115-
} -description 'Execute Pester and ScriptAnalyzer tests'
150+
Task Test -Depends $PSBTestDependency {
151+
} -Description 'Execute Pester and ScriptAnalyzer tests'
116152

117-
Task BuildHelp -depends $PSBPreference.TaskDependencies.BuildHelp {} -description 'Builds help documentation'
153+
Task BuildHelp -Depends $PSBBuildHelpDependency {} -Description 'Builds help documentation'
118154

119155
$genMarkdownPreReqs = {
120156
$result = $true
@@ -124,7 +160,7 @@ $genMarkdownPreReqs = {
124160
}
125161
$result
126162
}
127-
Task GenerateMarkdown -depends $PSBPreference.TaskDependencies.GenerateMarkdown -precondition $genMarkdownPreReqs {
163+
Task GenerateMarkdown -Depends $PSBGenerateMarkdownDependency -PreCondition $genMarkdownPreReqs {
128164
$buildMDParams = @{
129165
ModulePath = $PSBPreference.Build.ModuleOutDir
130166
ModuleName = $PSBPreference.General.ModuleName
@@ -136,7 +172,7 @@ Task GenerateMarkdown -depends $PSBPreference.TaskDependencies.GenerateMarkdown
136172
UseFullTypeName = $PSBPreference.Docs.UseFullTypeName
137173
}
138174
Build-PSBuildMarkdown @buildMDParams
139-
} -description 'Generates PlatyPS markdown files from module help'
175+
} -Description 'Generates PlatyPS markdown files from module help'
140176

141177
$genHelpFilesPreReqs = {
142178
$result = $true
@@ -146,9 +182,9 @@ $genHelpFilesPreReqs = {
146182
}
147183
$result
148184
}
149-
Task GenerateMAML -depends $PSBPreference.TaskDependencies.GenerateMAML -precondition $genHelpFilesPreReqs {
185+
Task GenerateMAML -Depends $PSBGenerateMAMLDependency -PreCondition $genHelpFilesPreReqs {
150186
Build-PSBuildMAMLHelp -Path $PSBPreference.Docs.RootDir -DestinationPath $PSBPreference.Build.ModuleOutDir
151-
} -description 'Generates MAML-based help from PlatyPS markdown files'
187+
} -Description 'Generates MAML-based help from PlatyPS markdown files'
152188

153189
$genUpdatableHelpPreReqs = {
154190
$result = $true
@@ -158,12 +194,12 @@ $genUpdatableHelpPreReqs = {
158194
}
159195
$result
160196
}
161-
Task GenerateUpdatableHelp -depends $PSBPreference.TaskDependencies.GenerateUpdatableHelp -precondition $genUpdatableHelpPreReqs {
197+
Task GenerateUpdatableHelp -Depends $PSBGenerateUpdatableHelpDependency -PreCondition $genUpdatableHelpPreReqs {
162198
Build-PSBuildUpdatableHelp -DocsPath $PSBPreference.Docs.RootDir -OutputPath $PSBPreference.Help.UpdatableHelpOutDir
163-
} -description 'Create updatable help .cab file based on PlatyPS markdown help'
199+
} -Description 'Create updatable help .cab file based on PlatyPS markdown help'
164200

165-
Task Publish -depends $PSBPreference.TaskDependencies.Publish {
166-
Assert -conditionToCheck ($PSBPreference.Publish.PSRepositoryApiKey -or $PSBPreference.Publish.PSRepositoryCredential) -failureMessage "API key or credential not defined to authenticate with [$($PSBPreference.Publish.PSRepository)] with."
201+
Task Publish -Depends $PSBPublishDependency {
202+
Assert -ConditionToCheck ($PSBPreference.Publish.PSRepositoryApiKey -or $PSBPreference.Publish.PSRepositoryCredential) -FailureMessage "API key or credential not defined to authenticate with [$($PSBPreference.Publish.PSRepository)] with."
167203

168204
$publishParams = @{
169205
Path = $PSBPreference.Build.ModuleOutDir
@@ -180,9 +216,9 @@ Task Publish -depends $PSBPreference.TaskDependencies.Publish {
180216
}
181217

182218
Publish-PSBuildModule @publishParams
183-
} -description 'Publish module to the defined PowerShell repository'
219+
} -Description 'Publish module to the defined PowerShell repository'
184220

185-
Task ? -description 'Lists the available tasks' {
221+
Task ? -Description 'Lists the available tasks' {
186222
'Available tasks:'
187223
$psake.context.Peek().Tasks.Keys | Sort-Object
188224
}

0 commit comments

Comments
 (0)