You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: restore Windows PowerShell 5.1 import compatibility
Get-PSBuildCertificate used the PowerShell 7+-only ternary operator, which
fails to parse under Windows PowerShell 5.1. The module loader dot-sources
every Public/*.ps1 at import, so this file broke import of the entire module
on 5.1 (Desktop) even though the manifest still declares support for it.
- Replace the ternary with an if/else expression (5.1-safe).
- Make the $IsWindows platform guard 5.1-safe using the repo's existing
idiom ($null -ne $IsWindows -and -not $IsWindows); on Desktop edition the
automatic variable is absent and the platform is always Windows. PS7
behavior is unchanged.
Add guardrails so this cannot silently regress:
- Enable PSUseCompatibleSyntax/Commands/Types (targeting 5.1 and 7.0) in
ScriptAnalyzerSettings.psd1, with justified suppressions for two
documented false positives (Get-ChildItem -CodeSigningCert provider
dynamic parameter; Invoke-Pester -Configuration from required Pester 5+).
- Fail the Analyze build task on any compatibility violation.
- Add an import-smoke CI job that parses and imports the module on the real
Windows PowerShell 5.1 engine.
The manifest support contract (PowerShellVersion/CompatiblePSEditions) is
intentionally left unchanged here; formalizing the real floor is tracked for
the v1.0.0 roadmap (#120).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: PowerShellBuild/Public/Get-PSBuildCertificate.ps1
+12-3Lines changed: 12 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -88,6 +88,11 @@ function Get-PSBuildCertificate {
88
88
'CertificatePasswordEnvVar',
89
89
Justification ='This is not a password in plain text. It is the name of an environment variable that contains the password, which is a common pattern for CI/CD pipelines and secrets management.'
Justification ='Get-ChildItem -CodeSigningCert is a dynamic parameter supplied by the Certificate (Cert:) provider, not a static parameter of Get-ChildItem, so the static command data used by PSUseCompatibleCommands cannot see it. It is available on both Windows PowerShell 5.1 and PowerShell 7+.'
Justification ='Invoke-Pester -Configuration is a Pester 5+ parameter. This module requires Pester >= 5.6.1 (see RequiredModules in the manifest) and imports Pester with -MinimumVersion 5.0.0 before use, so the parameter is always available at runtime. The bundled PSUseCompatibleCommands profiles captured an older Pester, producing a false positive on both Windows PowerShell 5.1 and PowerShell 7.'
0 commit comments