From 835b50a23bf9fdb2b2fc831b2253afd68f1c8ff6 Mon Sep 17 00:00:00 2001 From: Yves Fridelance Date: Thu, 26 Feb 2026 17:00:50 +0100 Subject: [PATCH 1/3] fix: suppress PSUseApprovedVerbs in PSScriptAnalyzer settings 'Build' is not in the official PS approved verbs list, causing PSScriptAnalyzer to warn on Build-PSModule in PowerShell 5.1. The verb is intentional and well-understood in this context. Co-Authored-By: Claude Opus 4.6 --- PSScriptAnalyzerSettings.psd1 | 1 + 1 file changed, 1 insertion(+) diff --git a/PSScriptAnalyzerSettings.psd1 b/PSScriptAnalyzerSettings.psd1 index 305b6cc..3e13bca 100644 --- a/PSScriptAnalyzerSettings.psd1 +++ b/PSScriptAnalyzerSettings.psd1 @@ -2,5 +2,6 @@ ExcludeRules = @( 'PSUseShouldProcessForStateChangingFunctions' 'PSUseSingularNouns' + 'PSUseApprovedVerbs' ) } From 249614f71cd72e03434f77a487128cc7ed267714 Mon Sep 17 00:00:00 2001 From: Yves Fridelance Date: Thu, 26 Feb 2026 17:10:21 +0100 Subject: [PATCH 2/3] fix: use 2-arg Join-Path in test for PS 5.1 compatibility Join-Path with 3+ positional arguments is a PS 7+ feature. In PS 5.1 this caused a terminating error in the BeforeAll of the 'Missing directories' context, cascading to all subsequent contexts (9 failures). Co-Authored-By: Claude Opus 4.6 --- Tests/Unit/Private/Resolve-ModuleSourcePaths.Tests.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tests/Unit/Private/Resolve-ModuleSourcePaths.Tests.ps1 b/Tests/Unit/Private/Resolve-ModuleSourcePaths.Tests.ps1 index 7974da9..714d875 100644 --- a/Tests/Unit/Private/Resolve-ModuleSourcePaths.Tests.ps1 +++ b/Tests/Unit/Private/Resolve-ModuleSourcePaths.Tests.ps1 @@ -112,7 +112,8 @@ Describe 'Resolve-ModuleSourcePaths' { # Create only a Public dir, no Enums/Classes/Private New-Item -Path (Join-Path $TempRoot 'Public') -ItemType Directory -Force | Out-Null - Set-Content -Path (Join-Path $TempRoot 'Public' 'Test-Func.ps1') -Value 'function Test-Func { }' + $PublicDir = Join-Path -Path $TempRoot -ChildPath 'Public' + Set-Content -Path (Join-Path -Path $PublicDir -ChildPath 'Test-Func.ps1') -Value 'function Test-Func { }' $Result = Resolve-ModuleSourcePaths -ModuleRoot $TempRoot } From d2767a14ad4b06d3fe8dca32892cc79b3de238e9 Mon Sep 17 00:00:00 2001 From: Yves Fridelance Date: Thu, 26 Feb 2026 17:17:31 +0100 Subject: [PATCH 3/3] fix: make Prerelease tests PS 5.1 compatible New-ModuleManifest in PS 5.1 does not generate the Prerelease field in the PSData section. The test BeforeEach now detects this and injects 'Prerelease = ''' into the PSData section before the closing brace, ensuring the tests work on both PS 5.1 and PS 7+. Co-Authored-By: Claude Opus 4.6 --- Tests/Unit/Private/Update-ManifestField.Tests.ps1 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Tests/Unit/Private/Update-ManifestField.Tests.ps1 b/Tests/Unit/Private/Update-ManifestField.Tests.ps1 index 229b1f4..a10b65c 100644 --- a/Tests/Unit/Private/Update-ManifestField.Tests.ps1 +++ b/Tests/Unit/Private/Update-ManifestField.Tests.ps1 @@ -161,9 +161,19 @@ Describe 'Update-ManifestField' { BeforeEach { # Create a fresh copy for each test Copy-Item -Path $Script:RefManifestPath -Destination $Script:PrereleaseManifestPath -Force - # Uncomment the Prerelease field so Update-ManifestField can locate and replace it + # Ensure the Prerelease field exists and is uncommented. + # PS 5.1 New-ModuleManifest may not generate the Prerelease field at all. $Content = [System.IO.File]::ReadAllText($Script:PrereleaseManifestPath, [System.Text.Encoding]::UTF8) - $Content = $Content -replace '# Prerelease = ''''', 'Prerelease = ''''' + if ($Content -match '# Prerelease = ') { + # PS 7+: uncomment the existing field + $Content = $Content -replace '# Prerelease = ''''', 'Prerelease = ''''' + } + elseif ($Content -notmatch '\bPrerelease\s*=') { + # PS 5.1: field missing entirely, inject into PSData section + $PsdMarker = ' } # End of PSData hashtable' + $Injection = " Prerelease = ''" + "`r`n" + "`r`n" + $PsdMarker + $Content = $Content.Replace($PsdMarker, $Injection) + } [System.IO.File]::WriteAllText($Script:PrereleaseManifestPath, $Content, [System.Text.UTF8Encoding]::new($true)) }