Repository navigation
fix(release): bring the build scripts in line with the 2.0 standards - #79
Conversation
Publish-Module.ps1 required PowerShell 7.4, which left support on 10 November 2026, and refused a package whose tags passed 4,000 characters. The PowerShell Gallery has no such limit on the list it shows, which carries two tags for every exported command, so the check could only refuse a release the Gallery would accept. The script now requires 7.6, counts a line break in ReleaseNotes and Description as two characters, and compares the staged module's exports with FunctionsToExport by name. It reads the API key from one vault, the default one or the one -VaultName names, as a SecureString that is converted to text only for the publish call. Build-Help.ps1 and Build-RuleReference.ps1 set strict mode, document every parameter and pass literal paths. The two PlatyPS commands that fail when strict mode is on in the calling scope run in a child scope with it off. The manifest drops its empty CompanyName; the packed metadata is the same without it. Closes #61
fadwen
left a comment
There was a problem hiding this comment.
Notes on the lines whose reason the diff does not show.
| # writes the release notes into the package with the line endings of the system that publishes, | ||
| # whatever the manifest has. | ||
| # | ||
| # The tags are not measured. The publish writes only the manifest's own tags and PSModule; the |
There was a problem hiding this comment.
The tag limit is removed, not raised. MOD-12 of the standards records a package with 6,709 characters of tags that the Gallery accepted. A package made from this branch with Compress-PSResource (PSResourceGet 1.2.1) carries PSModule Intune Remediation Win32 PSScriptAnalyzer Lint Endpoint Pester in its .nuspec and no tag for any command, which agrees with the Gallery adding the PSFunction_ and PSCommand_ tags itself.
|
|
||
| $vault = $VaultName | ||
| if (-not $vault) { | ||
| $defaultVaults = @(Get-SecretVault | Where-Object -Property IsDefault -EQ -Value $true) |
There was a problem hiding this comment.
Before this change Get-Secret was called without -Vault, which searches every registered vault. Reading only the default vault, or the one -VaultName names, is the behaviour change: a key stored in a second, non-default vault is no longer found unless the vault is named.
| throw "Staged module exported `$(`$commands.Count) command(s); the manifest declares $expectedCount." | ||
| `$commands = @((Get-Module $moduleName).ExportedFunctions.Keys | Sort-Object) | ||
| `$declared = @((Import-PowerShellDataFile -LiteralPath '$stagedManifest').FunctionsToExport | Sort-Object) | ||
| `$difference = @(Compare-Object -ReferenceObject `$declared -DifferenceObject `$commands) |
There was a problem hiding this comment.
The count comparison this replaces passed whenever the numbers matched. Run against a copy whose root module does not export Repair-IntuneScript, this now stops with Staged module's exports differ from the manifest's FunctionsToExport: Repair-IntuneScript (<=).
| Where-Object Filetype -match 'CommandHelp' | | ||
| Update-MarkdownCommandHelp -Path { $_.FilePath } | ||
| & { | ||
| Set-StrictMode -Off |
There was a problem hiding this comment.
Found by turning strict mode on for the whole script: the validation and the compile ran, and the signature update stopped inside PlatyPS. With strict mode on in the calling scope, Update-MarkdownCommandHelp and New-MarkdownCommandHelp (1.0.3) fail for Test-IntuneScript and pass for Get-IntuneAnalyzerRulePath, which has no parameters. Import-MarkdownCommandHelp, Test-MarkdownCommandHelp, Export-MamlCommandHelp and Update-MarkdownModuleFile are not affected, so only these two calls are scoped.
| ModuleVersion = '0.34.0' | ||
| GUID = '3f6b2c9e-7d41-4a8f-9c2b-5e0d8a1f4b76' | ||
| Author = 'Jeffrey Stuhr' | ||
| CompanyName = '' |
There was a problem hiding this comment.
Test-ModuleManifest reports an empty CompanyName with and without this line, and the .nuspec of the packed module is identical, so nothing the Gallery shows changes.
| It 'keeps the Gallery metadata within the limits the Gallery enforces: <Field>' -ForEach @( | ||
| @{ Field = 'ReleaseNotes'; Limit = 10600 } | ||
| @{ Field = 'Description'; Limit = 4000 } | ||
| @{ Field = 'Tags'; Limit = 4000 } |
There was a problem hiding this comment.
Removed together with the same check in Build/Publish-Module.ps1. The two remaining cases now count a line break as two characters, as the release script does.
fadwen
left a comment
There was a problem hiding this comment.
Verdict: approve.
Reviewed against ai-powershell-standards. Re-checked in a Linux sandbox with pwsh 7.6.0, Pester 6.2.0 and PSScriptAnalyzer 1.25.0.
Verified
#Requires -Version 7.6(VER-05).- Tag-limit removal: matches the reasoning in MOD-12.
- Release notes and description counted with a line break as two characters: same code as the MOD-12 sample.
- Exports compared name by name (MOD-11).
Get-Secretcalled with-Vault, without-AsPlainText; the key stays a SecureString until the publish call (SEC-50, SEC-07).Publish-Module.Tests.ps110/10, Module.Contract 15/15, RuleReference 4/4, all shuffled.Build-RuleReference.ps1 -PassThruoutput is the same asdocs/Rules.md.- PSScriptAnalyzer at Error and Warning, plus the ScriptSecurity preset, on the changed files: 0 findings.
Unverified (needs Windows): help XML byte-identical, Windows PowerShell 5.1 runs, full-suite counts. CI is green.
Nit: Publish-Module.ps1 still has positional Join-Path calls, such as Join-Path $PSScriptRoot 'Build-Help.ps1' and Join-Path $StagingPath $moduleName (STY-30).
Ten Join-Path calls in Publish-Module.ps1 still passed both paths by position, three of them inside the script that verifies the staged module in a new process. They name -Path and -ChildPath now, like the other calls in the build scripts (STY-14, STY-30). The staged paths are the same as before.
|
The nit from the review is addressed in 99e05ac.
|
Summary
Build/Publish-Module.ps1required PowerShell 7.4, which left support on 10 November 2026, and refused a package whose tags passed 4,000 characters, a limit the PowerShell Gallery does not have on the list it shows. Each exported command adds two tags to that list, so the check could only ever refuse a release the Gallery would accept. This change brings the three build scripts and the manifest in line with the module, version, error-handling, help and security rules of ai-powershell-standards 2.0.0. Closes #61.Changes
Publish-Module.ps1requires PowerShell 7.6 (VER-05).Module.Contract.Tests.ps1.ReleaseNotesandDescriptionare measured with a line break counted as two characters in both places (MOD-12).FunctionsToExport, where only the counts were compared (MOD-11).-VaultNameparameter names, and without-AsPlainText. It stays aSecureStringuntil thePublish-PSResourcecall (SEC-50, SEC-07). The reading is a function,Get-VaultApiKey, so that it can be tested without a vault.Build-Help.ps1andBuild-RuleReference.ps1set strict mode (ERR-01), document every parameter (DOC-01), build paths withJoin-Pathand pass them as-LiteralPath(STY-30, STY-32), and no longer assign to their own parameters (STY-16).Build-RuleReference.ps1are advanced functions with typed parameters, output types and help.Export-IslMamlinBuild-Help.ps1had one caller and is now inline (FUN-01, DOC-01, FUN-20).Build-Help.ps1refuses any placeholder in double braces, where it looked for{{ Fillonly (PLT-06), and its help namespowershell-platyps.instructions.md, the file that replacedplatyps.instructions.md.CompanyName = ''(MOD-03, DOC-18).Tests/Unit/Build/Publish-Module.Tests.ps1, ten tests for the vault reading and for the script's#Requiresversion.CHANGELOG.mdand the release paragraph ofCLAUDE.mddescribe the new behaviour.Verification
Run on Windows 11 26H2 with PowerShell 7.6.10 and Windows PowerShell 5.1.26100.
Test-StandardsCompliance.ps1overBuild/: 0 findings, down from 39. Over the new test file: 0../Build/Build-RuleReference.ps1 -PassThruequals the committeddocs/Rules.mdon both PowerShell versions../Build/Build-Help.ps1with-ValidateOnly, with-SkipUpdateand with neither: each passes, anden-US/IntuneScriptLab-Help.xmlis byte for byte the committed file after each. With one command's Markdown removed, the first-time generation runs and the build then stops on the placeholders it wrote, as before../Build/Publish-Module.ps1 -WhatIf, with and without-SkipHelpBuild: passes, 81 files staged.Repair-IntuneScript, the rehearsal stops withStaged module's exports differ from the manifest's FunctionsToExport: Repair-IntuneScript (<=).Get-SecretandGet-SecretVaultreplaced by stand-ins, so that no real vault and no Gallery was involved: the default vault is read with-Vaultand without-AsPlainText,-VaultNameis passed through,-ApiKeyand$env:PSGALLERY_API_KEYare used without reading the vault, a vault without the secret gives a warning and the "No PowerShell Gallery API key found" error, the realPublish-PSResourcewritesIntuneScriptLab.0.34.0.nupkg, and a second run is refused because the version exists..nuspecof a package made withCompress-PSResourceis identical with and without theCompanyNamekey.mainon this computer and pass in CI. The fourth is the order-dependent test of A Get-IslAgentLogEvent test fails when the shuffle runs it first in its file #78, under shuffle seed 1788100338; its file passes when run alone.Notes
Update-MarkdownCommandHelpandNew-MarkdownCommandHelpof Microsoft.PowerShell.PlatyPS 1.0.3 end withThe property 'defaultValue' cannot be found on this objectfor a command that has parameters when strict mode is on in the scope that calls them.Build-Help.ps1therefore calls those two in a child scope with strict mode off, with a comment that says so. Strict mode stays on for the rest of the script.-VaultName. The release workflow is not affected: it passes the key inPSGALLERY_API_KEY.