Skip to content

Commit 00ecf0b

Browse files
Merge pull request #164 from PowershellFrameworkCollective/actionsExt
2.2.10.128
2 parents 5ff669a + df78d60 commit 00ecf0b

16 files changed

+206
-22
lines changed

PSModuleDevelopment/PSModuleDevelopment.psd1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
RootModule = 'PSModuleDevelopment.psm1'
55

66
# Version number of this module.
7-
ModuleVersion = '2.2.10.123'
7+
ModuleVersion = '2.2.10.128'
88

99
# ID used to uniquely identify this module
1010
GUID = '37dd5fce-e7b5-4d57-ac37-832055ce49d6'
@@ -27,8 +27,8 @@
2727
# Modules that must be imported into the global environment prior to importing
2828
# this module
2929
RequiredModules = @(
30-
@{ ModuleName = 'PSFramework'; ModuleVersion = '1.6.198' }
31-
@{ ModuleName = 'string'; ModuleVersion = '0.6.1' }
30+
@{ ModuleName = 'PSFramework'; ModuleVersion = '1.6.205' }
31+
@{ ModuleName = 'string'; ModuleVersion = '1.0.0' }
3232
)
3333

3434
# Assemblies that must be loaded prior to importing this module
512 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

PSModuleDevelopment/bin/PSModuleDevelopment.xml

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PSModuleDevelopment/changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 2.2.10.128 (2021-11-11)
4+
5+
+ New: Action: deployModule - Deploys a module to the target computer(s)
6+
+ Upd: Invoke-PSMDBuildProject - Added parameter resolution from artifacts and configuration
7+
+ Upd: Invoke-PSMDBuildProject - Added automatic artifacts resolution based on value of a parameter: %!Name!% will be resolved to the artifact named "Name".
8+
+ Upd: Invoke-PSMDBuildProject - Added `-InheritArtifacts` parameter to allow keeping artifacts around created before starting the pipeline
9+
+ Fix: Invoke-PSMDTemplate - Invoking templates on PS5.1 fails with invalid replace
10+
311
## 2.2.10.123 (2021-07-21)
412

513
- Fix: Template PSFProject - fixed string test modulename

PSModuleDevelopment/functions/build/Invoke-PSMDBuildProject.ps1

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,27 @@
1818
Mandatory if no build project has been selected as the default project.
1919
Use the Select-PSMDBuildProject to define a default project (and optionally persist the choice across sessions)
2020
21+
.PARAMETER InheritArtifacts
22+
Accept artifacts that were generated before ever executing this pipeline.
23+
By default, any artifacts previously provisioned are cleared on pipeline start.
24+
2125
.PARAMETER RetainArtifacts
2226
Whether, after executing the project, its artifacts should be retained.
2327
By default, any artifacts created during a build project will be discarded upon project completion.
24-
28+
2529
Artifacts are similar to variables to the pipeline and can be used to pass data throughout the pipeline.
2630
2731
+ Use Publish-PSMDBuildArtifact to create a new artifact.
2832
+ Use Get-PSMDBuildArtifact to access existing build artifacts.
2933
3034
.EXAMPLE
3135
PS C:\> Invoke-PSMDBuildProject -Path .\VMDeployment.build.Json
32-
36+
3337
Execute the build file "VMDeployment.build.json" from the current folder
3438
3539
.EXAMPLE
3640
PS C:\> build
37-
41+
3842
Execute the default build project.
3943
#>
4044
[Alias('build')]
@@ -43,12 +47,17 @@
4347
[string]
4448
$Path,
4549

50+
[switch]
51+
$InheritArtifacts,
52+
4653
[switch]
4754
$RetainArtifacts
4855
)
4956

5057
begin {
51-
$script:buildArtifacts = @{ }
58+
if (-not $InheritArtifacts) {
59+
$script:buildArtifacts = @{ }
60+
}
5261
$buildStatus = @{ }
5362

5463
$projectPath = $Path
@@ -158,6 +167,10 @@
158167
}
159168
if (-not $parameters.Parameters) { $parameters.Parameters = @{ } }
160169
if (-not $parameters.ParametersFromArtifacts) { $parameters.ParametersFromArtifacts = @{ } }
170+
171+
# Resolve Parameters
172+
$parameters.Parameters = Resolve-PSMDBuildStepParameter -Parameters $parameters.Parameters -FromArtifacts $parameters.ParametersFromArtifacts -ProjectName $parameters.ProjectName -StepName $parameters.StepName
173+
161174
try { $null = & $actionObject.Action $parameters }
162175
catch {
163176
Write-StepResult @resultDef -Status Failed -Data $_ -ContinueLabel main

PSModuleDevelopment/functions/build/Resolve-PSMDBuildStepParameter.ps1

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
function Resolve-PSMDBuildStepParameter {
22
<#
33
.SYNOPSIS
4-
Update missing build action parameters from the configuration system.
4+
Resolves and consolidates the overall parameters of a given step.
55
66
.DESCRIPTION
7-
Update missing build action parameters from the configuration system.
8-
This command is for use within the defined code of build actions.
7+
Resolves and consolidates the overall parameters of a given step.
8+
This ensures that individual actions do not have to implement manual resolution and complex conditionals.
9+
Sources of parameters:
10+
- Explicitly defined parameter in the step
11+
- Value from Artifacts
12+
- Value from Configuration (only if not otherwise sourced)
13+
- Value from implicit artifact resolution: Any value that is formatted like this:
14+
"%!NameOfArtifact!%" will be replaced with the value of the artifact of the same name.
15+
This supports wildcard resolution, so "%!Session.*!%" will resolve to all artifacts with a name starting with "Session."
916
1017
.PARAMETER Parameters
1118
The hashtable containing the currently specified parameters from the step configuration within the build project file.
@@ -64,6 +71,14 @@
6471
$Parameters[$pair.Key] = (Get-PSMDBuildArtifact -Name $pair.Value).Value
6572
}
6673

74+
# Resolve implicit artifact references
75+
foreach ($key in $($Parameters.Keys)) {
76+
if ($Parameters.$key -notlike '%!*!%') { continue }
77+
78+
$artifactName = $Parameters.$key -replace '^%!(.+?)!%$', '$1'
79+
$Parameters[$Key] = (Get-PSMDBuildArtifact -Name $artifactName).Value
80+
}
81+
6782
$Parameters
6883
}
6984
}

PSModuleDevelopment/functions/templating/Invoke-PSMDTemplate.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,10 @@
320320
$fileName = $Item.Name
321321
if (-not $Raw) {
322322
foreach ($param in $Item.FileSystemParameterFlat) {
323-
$fileName = $fileName.Replace("$($identifier)$($param)$($identifier)", $ParameterFlat[$param], $true, $null)
323+
$fileName = [PSModuleDevelopment.Utility.UtilityHost]::Replace($fileName,"$($identifier)$($param)$($identifier)", $ParameterFlat[$param], $false)
324324
}
325325
foreach ($param in $Item.FileSystemParameterScript) {
326-
$fileName = $fileName.Replace("$($identifier)$($param)$($identifier)", $ParameterScript[$param], $true, $null)
326+
$fileName = [PSModuleDevelopment.Utility.UtilityHost]::Replace($fileName, "$($identifier)$($param)$($identifier)", $ParameterScript[$param], $false)
327327
}
328328
}
329329
$destPath = Join-Path $Path $fileName
@@ -332,10 +332,10 @@
332332
$text = $Item.Value
333333
if (-not $Raw) {
334334
foreach ($param in $Item.ContentParameterFlat) {
335-
$text = $text.Replace("$($identifier)$($param)$($identifier)", $ParameterFlat[$param], $true, $null)
335+
$text = [PSModuleDevelopment.Utility.UtilityHost]::Replace($text, "$($identifier)$($param)$($identifier)", $ParameterFlat[$param], $false)
336336
}
337337
foreach ($param in $Item.ContentParameterScript) {
338-
$text = $text.Replace("$($identifier)!$($param)!$($identifier)", $ParameterScript[$param], $true, $null)
338+
$text = [PSModuleDevelopment.Utility.UtilityHost]::Replace($text, "$($identifier)!$($param)!$($identifier)", $ParameterScript[$param], $false)
339339
}
340340
}
341341
[System.IO.File]::WriteAllText($destPath, $text, $Encoding)

PSModuleDevelopment/internal/buildActions/command.action.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
$rootPath = $Parameters.RootPath
77
$actualParameters = $Parameters.Parameters
8-
$actualParameters = Resolve-PSMDBuildStepParameter -Parameters $actualParameters -FromArtifacts $Parameters.ParametersFromArtifacts -ProjectName $Parameters.ProjectName -StepName $Parameters.StepName
98

109
#region Process Parameters
1110
if (-not $actualParameters.Command) {

PSModuleDevelopment/internal/buildActions/copy-item.action.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
$rootPath = $Parameters.RootPath
77
$actualParameters = $Parameters.Parameters
8-
$actualParameters = Resolve-PSMDBuildStepParameter -Parameters $actualParameters -FromArtifacts $Parameters.ParametersFromArtifacts -ProjectName $Parameters.ProjectName -StepName $Parameters.StepName
98

109
#region Utility Functions
1110
function ConvertTo-PSSession {

0 commit comments

Comments
 (0)