Skip to content

fix(release): bring the build scripts in line with the 2.0 standards - #79

Merged
fadwen merged 2 commits into
mainfrom
fix/release-script-standards
Nov 23, 2026
Merged

fadwen merged 2 commits into
mainfrom
fix/release-script-standards

Conversation

@fadwen

@fadwen fadwen commented Nov 22, 2026

Copy link
Copy Markdown
Owner

Summary

Build/Publish-Module.ps1 required 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.ps1 requires PowerShell 7.6 (VER-05).
  • The tag limit is gone from the release script and from Module.Contract.Tests.ps1. ReleaseNotes and Description are measured with a line break counted as two characters in both places (MOD-12).
  • The staged module's exported names are compared with the staged manifest's FunctionsToExport, where only the counts were compared (MOD-11).
  • The API key is read from one vault, the default one or the one the new -VaultName parameter names, and without -AsPlainText. It stays a SecureString until the Publish-PSResource call (SEC-50, SEC-07). The reading is a function, Get-VaultApiKey, so that it can be tested without a vault.
  • Build-Help.ps1 and Build-RuleReference.ps1 set strict mode (ERR-01), document every parameter (DOC-01), build paths with Join-Path and pass them as -LiteralPath (STY-30, STY-32), and no longer assign to their own parameters (STY-16).
  • The helper functions of Build-RuleReference.ps1 are advanced functions with typed parameters, output types and help. Export-IslMaml in Build-Help.ps1 had one caller and is now inline (FUN-01, DOC-01, FUN-20).
  • Build-Help.ps1 refuses any placeholder in double braces, where it looked for {{ Fill only (PLT-06), and its help names powershell-platyps.instructions.md, the file that replaced platyps.instructions.md.
  • The manifest no longer sets CompanyName = '' (MOD-03, DOC-18).
  • New: Tests/Unit/Build/Publish-Module.Tests.ps1, ten tests for the vault reading and for the script's #Requires version.
  • CHANGELOG.md and the release paragraph of CLAUDE.md describe the new behaviour.

Verification

Run on Windows 11 26H2 with PowerShell 7.6.10 and Windows PowerShell 5.1.26100.

  • PSScriptAnalyzer 1.25.0 as CI runs it (default rules, Error and Warning, 176 files): 0 findings. No line over 115 characters.
  • The standards' Test-StandardsCompliance.ps1 over Build/: 0 findings, down from 39. Over the new test file: 0.
  • ./Build/Build-RuleReference.ps1 -PassThru equals the committed docs/Rules.md on both PowerShell versions.
  • ./Build/Build-Help.ps1 with -ValidateOnly, with -SkipUpdate and with neither: each passes, and en-US/IntuneScriptLab-Help.xml is 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.
  • Against a copy of the repository whose root module does not export Repair-IntuneScript, the rehearsal stops with Staged module's exports differ from the manifest's FunctionsToExport: Repair-IntuneScript (<=).
  • The script end to end against a temporary local file-system repository, with Get-Secret and Get-SecretVault replaced by stand-ins, so that no real vault and no Gallery was involved: the default vault is read with -Vault and without -AsPlainText, -VaultName is passed through, -ApiKey and $env:PSGALLERY_API_KEY are used without reading the vault, a vault without the secret gives a warning and the "No PowerShell Gallery API key found" error, the real Publish-PSResource writes IntuneScriptLab.0.34.0.nupkg, and a second run is refused because the version exists.
  • The .nuspec of a package made with Compress-PSResource is identical with and without the CompanyName key.
  • Pester, full suite, shuffled, PowerShell 7.6.10: 1,052 tests, 1,040 passed, 8 skipped, 4 failed, coverage 95.11 percent. Three failures are the ones Repair-IntuneScript corrupts an ANSI script on a host with a UTF-8 system code page #75 and In-box module table does not list UOPProviders, present on Windows 11 26H2 #76 describe, which fail the same way on main on 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.
  • Pester, full suite, shuffled, Windows PowerShell 5.1: 1,052 tests, 1,005 passed, 44 skipped, 3 failed, the three of Repair-IntuneScript corrupts an ANSI script on a host with a UTF-8 system code page #75 and In-box module table does not list UOPProviders, present on Windows 11 26H2 #76.

Notes

  • This is the first pull request of a stack for Bring the module into line with ai-powershell-standards 2.0.0 (tracking) #77. The next one is based on this branch.
  • Update-MarkdownCommandHelp and New-MarkdownCommandHelp of Microsoft.PowerShell.PlatyPS 1.0.3 end with The property 'defaultValue' cannot be found on this object for a command that has parameters when strict mode is on in the scope that calls them. Build-Help.ps1 therefore 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.
  • A locally stored key in a vault that is not the default one is no longer found without -VaultName. The release workflow is not affected: it passes the key in PSGALLERY_API_KEY.

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 fadwen left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notes on the lines whose reason the diff does not show.

Comment thread Build/Publish-Module.ps1
# 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

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread Build/Publish-Module.ps1

$vault = $VaultName
if (-not $vault) {
$defaultVaults = @(Get-SecretVault | Where-Object -Property IsDefault -EQ -Value $true)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread Build/Publish-Module.ps1
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)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (<=).

Comment thread Build/Build-Help.ps1
Where-Object Filetype -match 'CommandHelp' |
Update-MarkdownCommandHelp -Path { $_.FilePath }
& {
Set-StrictMode -Off

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread IntuneScriptLab.psd1
ModuleVersion = '0.34.0'
GUID = '3f6b2c9e-7d41-4a8f-9c2b-5e0d8a1f4b76'
Author = 'Jeffrey Stuhr'
CompanyName = ''

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 }

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 fadwen left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-Secret called with -Vault, without -AsPlainText; the key stays a SecureString until the publish call (SEC-50, SEC-07).
  • Publish-Module.Tests.ps1 10/10, Module.Contract 15/15, RuleReference 4/4, all shuffled.
  • Build-RuleReference.ps1 -PassThru output is the same as docs/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.
@fadwen

fadwen commented Nov 23, 2026

Copy link
Copy Markdown
Owner Author

The nit from the review is addressed in 99e05ac.

  • Positional Join-Path calls: the ten calls in Build/Publish-Module.ps1 that passed both paths by position now name -Path and -ChildPath, including the three inside the script that verifies the staged module in a new process. No other build script had one.
  • Checked after the change: PSScriptAnalyzer at Error and Warning on the file reports nothing, the 10 tests of Publish-Module.Tests.ps1 pass, ./Build/Publish-Module.ps1 -WhatIf stages and verifies the module as before, and the workflow passed on the commit (run 45144457970).

@fadwen
fadwen merged commit df694ae into main Nov 23, 2026
4 checks passed
@fadwen
fadwen deleted the fix/release-script-standards branch November 23, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build and release scripts depart from the 2.0 standards (VER-05, MOD-12, SEC-50, ERR-01)

1 participant