Skip to content

Commit 14e8a41

Browse files
authored
Fix Deploy Pipeline Step (#60)
* Update files from Sampler * See if this fixes the manifest * Update changelog * Add sampler config for MainGitBranch
1 parent 10aa5fc commit 14e8a41

File tree

5 files changed

+51
-42
lines changed

5 files changed

+51
-42
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Updated repository files from Sampler template.
1313
- Fixed README.
1414
- Use PublishCodeCoverageResults@2.
15+
- Fix deploy step. [Fixes #45](https://github.com/dsccommunity/SChannelDsc/issues/45)
1516
- Renamed `master` branch to `main` - Fixes [Issue #41](https://github.com/dsccommunity/SChannelDsc/issues/41)
1617

1718
## [1.4.0] - 2022-05-17

Resolve-Dependency.ps1

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ if ($UseModuleFast -and -not (Get-Module -Name 'ModuleFast'))
233233

234234
$moduleFastBootstrapScriptBlockParameters.UseMain = $true
235235
}
236-
elseif($ModuleFastVersion)
236+
elseif ($ModuleFastVersion)
237237
{
238238
if ($ModuleFastVersion -notmatch 'v')
239239
{
@@ -345,7 +345,7 @@ if ($UsePSResourceGet)
345345
Force = $true
346346
}
347347

348-
Expand-Archive @expandArchiveParameters
348+
Microsoft.PowerShell.Archive\Expand-Archive @expandArchiveParameters
349349

350350
Remove-Item -Path $psResourceGetZipArchivePath
351351

@@ -866,9 +866,24 @@ try
866866
if ($moduleFastPlan)
867867
{
868868
# Clear all modules in plan from the current session so they can be fetched again.
869-
$moduleFastPlan.Name | Get-Module | Remove-Module -Force
870-
871-
$moduleFastPlan | Install-ModuleFast @installModuleFastParameters
869+
try
870+
{
871+
$moduleFastPlan.Name | Get-Module | Remove-Module -Force
872+
$moduleFastPlan | Install-ModuleFast @installModuleFastParameters
873+
}
874+
catch
875+
{
876+
Write-Warning -Message 'ModuleFast could not save one or more dependencies. Retrying...'
877+
try
878+
{
879+
$moduleFastPlan.Name | Get-Module | Remove-Module -Force
880+
$moduleFastPlan | Install-ModuleFast @installModuleFastParameters
881+
}
882+
catch
883+
{
884+
Write-Error 'ModuleFast could not save one or more dependencies even after a retry.'
885+
}
886+
}
872887
}
873888
else
874889
{

build.ps1

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
The default value is '' (empty string).
1111
1212
.PARAMETER BuildConfig
13-
Not yet written.
13+
Path to a file with configuration. Supported extensions : psd1, yaml, yml, json, jsonc.
1414
1515
.PARAMETER OutputDirectory
1616
Specifies the folder to build the artefact into. The default value is 'output'.
@@ -22,7 +22,7 @@
2222
.PARAMETER RequiredModulesDirectory
2323
Can be a path (relative to $PSScriptRoot or absolute) to tell Resolve-Dependency
2424
and PSDepend where to save the required modules. It is also possible to use
25-
'CurrentUser' och 'AllUsers' to install missing dependencies. You can override
25+
'CurrentUser' or 'AllUsers' to install missing dependencies. You can override
2626
the value for PSDepend in the Build.psd1 build manifest. The default value is
2727
'output/RequiredModules'.
2828
@@ -49,13 +49,13 @@
4949
used in the DscResource.Test.build.ps1 tasks.
5050
5151
.PARAMETER ResolveDependency
52-
Not yet written.
52+
Resolve missing dependencies.
5353
5454
.PARAMETER BuildInfo
5555
The build info object from ModuleBuilder. Defaults to an empty hashtable.
5656
5757
.PARAMETER AutoRestore
58-
Not yet written.
58+
Specifies to restore the required modules by running build.ps1 with ResolveDependency switch and empty task `noop`.
5959
6060
.PARAMETER UseModuleFast
6161
Specifies to use ModuleFast instead of PowerShellGet to resolve dependencies
@@ -70,6 +70,7 @@
7070
only works then the method of downloading dependencies is PSResourceGet.
7171
This can also be configured in Resolve-Dependency.psd1.
7272
#>
73+
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because how $PSDependTarget is assigned to splatting variable $resolveDependencyParams.')]
7374
[CmdletBinding()]
7475
param
7576
(
@@ -296,14 +297,17 @@ process
296297

297298
foreach ($TaskToExport in $BuildInfo['ModuleBuildTasks'].($module))
298299
{
299-
$loadedModule.ExportedAliases.GetEnumerator().Where{
300-
Write-Host -Object "`t Loading $($_.Key)..." -ForegroundColor DarkGray
301-
300+
$aliasTasks = $loadedModule.ExportedAliases.GetEnumerator().Where{
302301
# Using -like to support wildcard.
303302
$_.Key -like $TaskToExport
304-
}.ForEach{
303+
}
304+
305+
foreach ($aliasTask in $aliasTasks)
306+
{
307+
Write-Host -Object "`t Loading $($aliasTask.Key)..." -ForegroundColor DarkGray
308+
305309
# Dot-sourcing the Tasks via their exported aliases.
306-
. (Get-Alias $_.Key)
310+
. (Get-Alias $aliasTask.Key)
307311
}
308312
}
309313
}
@@ -317,12 +321,13 @@ process
317321
}
318322

319323
# Loading Build Tasks defined in the .build/ folder (will override the ones imported above if same task name).
320-
Get-ChildItem -Path '.build/' -Recurse -Include '*.ps1' -ErrorAction Ignore |
321-
ForEach-Object {
322-
"Importing file $($_.BaseName)" | Write-Verbose
324+
$taskFiles = Get-ChildItem -Path '.build/' -Recurse -Include '*.ps1' -ErrorAction Ignore
325+
foreach ($taskFile in $taskFiles)
326+
{
327+
"Importing file $($taskFile.BaseName)" | Write-Verbose
323328

324-
. $_.FullName
325-
}
329+
. $taskFile.FullName
330+
}
326331

327332
# Synopsis: Empty task, useful to test the bootstrap process.
328333
task noop { }
@@ -352,7 +357,6 @@ process
352357
}
353358

354359
Write-Host -Object "[build] Executing requested workflow: $($Tasks -join ', ')" -ForeGroundColor Magenta
355-
356360
}
357361
finally
358362
{
@@ -493,7 +497,7 @@ begin
493497
{
494498
$paramValue = $MyInvocation.BoundParameters.Item($cmdParameter)
495499

496-
Write-Debug " adding $cmdParameter :: $paramValue [from user-provided parameters to Build.ps1]"
500+
Write-Debug -Message " adding $cmdParameter :: $paramValue [from user-provided parameters to Build.ps1]"
497501

498502
$resolveDependencyParams.Add($cmdParameter, $paramValue)
499503
}
@@ -504,7 +508,7 @@ begin
504508

505509
if ($paramValue)
506510
{
507-
Write-Debug " adding $cmdParameter :: $paramValue [from default Build.ps1 variable]"
511+
Write-Debug -Message " adding $cmdParameter :: $paramValue [from default Build.ps1 variable]"
508512

509513
$resolveDependencyParams.Add($cmdParameter, $paramValue)
510514
}

build.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ DscTest:
8484
- output
8585
ExcludeModuleFile:
8686
- Modules/DscResource.Common
87+
MainGitBranch: main
8788

8889
# Import ModuleBuilder tasks from a specific PowerShell module using the build
8990
# task's alias. Wildcard * can be used to specify all tasks that has a similar

source/SChannelDsc.psd1

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
1-
#
2-
# Module manifest for module 'SChannelDsc'
3-
#
4-
# Generated by: DSC Community
5-
#
6-
# Generated on: 10/02/2022
7-
#
8-
91
@{
10-
112
# Script module or binary module file associated with this manifest.
12-
RootModule = 'SchannelDsc.psm1'
3+
RootModule = 'SChannelDsc.psm1'
134

145
# Version number of this module.
156
ModuleVersion = '0.0.1'
@@ -27,7 +18,7 @@
2718
CompanyName = 'DSC Community'
2819

2920
# Copyright statement for this module
30-
Copyright = '(c) DSC Community. All rights reserved.'
21+
Copyright = 'Copyright the DSC Community contributors. All rights reserved.'
3122

3223
# Description of the functionality provided by this module
3324
Description = 'This DSC module is used to manage Secure Channel (SChannel) configurations.'
@@ -51,22 +42,19 @@
5142
# ProcessorArchitecture = ''
5243

5344
# Modules that must be imported into the global environment prior to importing this module
54-
RequiredModules = @()
45+
RequiredModules = @()
5546

5647
# Assemblies that must be loaded prior to importing this module
57-
# RequiredAssemblies = @()
48+
RequiredAssemblies = @()
5849

5950
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
60-
# ScriptsToProcess = @()
51+
ScriptsToProcess = @()
6152

6253
# Type files (.ps1xml) to be loaded when importing this module
63-
# TypesToProcess = @()
54+
TypesToProcess = @()
6455

6556
# Format files (.ps1xml) to be loaded when importing this module
66-
# FormatsToProcess = @()
67-
68-
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
69-
NestedModules = @()
57+
FormatsToProcess = @()
7058

7159
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
7260
FunctionsToExport = @()
@@ -87,7 +75,7 @@
8775
# ModuleList = @()
8876

8977
# List of all files packaged with this module
90-
# FileList = @()
78+
FileList = @()
9179

9280
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
9381
PrivateData = @{

0 commit comments

Comments
 (0)