Uh oh!
There was an error while loading. Please reload this page.
chore: Move the build toolchain to psake 5.0.4 - #162
Conversation
BuildHelpers' Get-BuildVariable uses `break` inside switch blocks. Called from a Pester BeforeAll, that break can unwind out of the block. psake 4.9.x absorbs it; psake 5.x does not, so Pester fails the whole Manifest.tests.ps1 container (pester/Pester#2669) and the suite drops 12 tests. build.ps1 already calls Set-BuildEnvironment -Force before Invoke-psake, so inside a build the call in BeforeAll is redundant. Guard it on $env:BHProjectName: a no-op during a build, still populated for standalone Invoke-Pester runs. Found while spiking psake 5.0.4 for #155. Verified: full suite 428 passed / 0 failed under both psake 4.9.1 and 5.0.4, and 10/0 standalone with a cleared environment. Refs #155 (cherry picked from commit 5ec9a01)
Bumps psake from 4.9.0 to 5.0.4 in requirements.psd1. The module manifest still requires psake 4.9.0 or newer: PowerShellBuild's task definitions are unchanged and run on both majors, so consumers are not forced to upgrade. This mirrors the Pester decision in #120 -- raising a consumer-facing minimum for no functional gain is not worth the churn. The #155 spike verified the whole surface: task names, task dependencies, and the $PSBPreference contract are identical under 5.0.4, and none of the four breaking changes in psake's own v4-to-v5 guide apply here. Full suite is 428 passed / 0 failed under both psake 4.9.1 and 5.0.4. Two consumer-visible psake 5.x behaviors are documented in the migration guide: Invoke-psake now returns a PsakeBuildResult where v4 returned nothing, and Pester tests calling Set-BuildEnvironment in a BeforeAll can fail the whole container. The second is undocumented upstream and was found by the spike. Closes#161
There was a problem hiding this comment.
Pull request overview
Updates the repository’s build/test toolchain to use psake 5.0.4 while keeping the module manifest’s consumer minimum at psake 4.9.0, and documents the resulting consumer-visible behavior changes for psake 5.x adopters.
Changes:
- Bump the pinned build dependency in
requirements.psd1from psake 4.9.0 to 5.0.4. - Add a guard in
tests/Manifest.tests.ps1to avoid callingSet-BuildEnvironmentwhen BuildHelpers variables are already present. - Document psake 5.x behavioral differences in the migration guide and record the bump in the changelog.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
requirements.psd1 | Pins psake to 5.0.4 for this repo’s build/tooling dependency set. |
tests/Manifest.tests.ps1 | Guards Set-BuildEnvironment in BeforeAll to avoid a psake 5.x container-failing edge case. |
docs/migration-v0.8-to-v1.0.md | Adds a migration entry explaining psake 5.x behavior changes and mitigations. |
CHANGELOG.md | Adds an Unreleased note describing the toolchain bump and links to migration guidance. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Uh oh!
There was an error while loading. Please reload this page.
tablackburn
commented
Aug 20, 2026
CI is green on every leg, including That was the one thing this PR could not verify locally — the #155 spike and my local runs were pwsh 7.6.5 on Windows only, and Windows PowerShell 5.1 is a supported v1.0.0 floor. psake 5.0.4 works on 5.1, so the last open question about the psake bump is settled and I have cleared it from #120's fog. The other reviewer note stands and is a genuine judgement call for you: CI now exercises only psake 5.0.4 while the manifest still claims |
Neither belongs: this change is not user-facing. requirements.psd1 is this repository's own build toolchain, not anything a consumer touches, and the manifest's RequiredModules floor deliberately stays at psake 4.9.0 -- so upgrading PowerShellBuild 0.8.x to 1.0.0 does not move anyone to psake 5.x. The changelog records user-facing changes. The migration guide's stated scope is breaking changes plus behavioral changes that can require action when upgrading PowerShellBuild; the psake 5.x behaviors are triggered by upgrading psake, not PowerShellBuild, and psake's own v4-to-v5 guide is their proper home. If a later change raises the manifest floor to psake 5.x, that change adds the migration entry, where it will be correct. The Set-BuildEnvironment interaction stays documented where it is actionable: the comment in tests/Manifest.tests.ps1 and the spike findings in #155.
Summary
requirements.psd1Set-BuildEnvironmentcall intests/Manifest.tests.ps1, without which psake 5.xfails the whole test container and the suite silently loses 12 tests
Two files, +7 −2. Scope and shape come from the #155 spike, which found this is a single small
PR rather than a chain. Closes#161.
What did not change, deliberately
The manifest's
RequiredModulesfloor stays atpsake4.9.0. PowerShellBuild's taskdefinitions are unchanged and run on both majors — task names, task dependencies, and the
$PSBPreferencecontract are identical under 5.0.4 — so raising the floor would force anupgrade on consumers for no functional gain. This mirrors the Pester decision recorded in #120
(
RequiredModulesstayed at 5.6.1 for the same reason).No changelog or migration-guide entry.
requirements.psd1is this repository's own buildtoolchain, not anything a consumer touches, and because the manifest floor is unchanged,
upgrading PowerShellBuild 0.8.x → 1.0.0 does not move anyone to psake 5.x. The psake 5.x
behavior differences are triggered by upgrading psake, and
psake's own v4 → v5 guide
is their proper home. If a later change raises the manifest floor to psake 5.x, that change
adds the migration entry, where it will be correct. (Recorded as the "Changelog and guide
scope" decision on #120.)
Also out of scope, per #155: psake 5.x's
Version 5declaration andProperties @{}hashtablesyntax are available but not adopted here, and none of the #117 extras (task caching, LLM
output,
Format-PSBuildResult) come along.The test guard
tests/Manifest.tests.ps1calledSet-BuildEnvironment -ForceinBeforeAll. BuildHelpers'Get-BuildVariableusesbreakinsideswitchblocks, and thatbreakcan unwind out of theblock. psake 4.9.x's task invocation absorbs it; psake 5.x's does not, so Pester fails the
entire container (pester/Pester#2669) and the
suite silently drops from 428 to 418 passing.
build.ps1callsSet-BuildEnvironment -Forceunconditionally beforeInvoke-psake(
build.ps1:56), so by the time thisBeforeAllruns the variables are already set and thesecond call is redundant. Guarding on that makes it short-circuit during a build, so the
escaping
breaknever fires. The complete change totests/Manifest.tests.ps1:BeforeAll { # Only call Set-BuildEnvironment when the build variables are not already present.# build.ps1 sets them before Invoke-psake, so inside a build this is a no-op; standalone# Pester runs still get them. Calling it unconditionally lets an escaping 'break' from# BuildHelpers' Get-BuildVariable switch blocks unwind out of this BeforeAll, which# psake 4.9.x absorbs but psake 5.x does not -- Pester then fails the whole container.if (-not$env:BHProjectName) { Set-BuildEnvironment-Force } ...build.ps1itself is not modified by this PR. A dummy enclosing loop does not absorb thebreak — tested and rejected.
This interaction is not documented upstream. It stays recorded where it is actionable: the
comment above, and the full spike findings in #155. Worth reporting to BuildHelpers separately.
Test Plan
forced to upgrade" claim; the manifest still allows 4.9.x)
Invoke-Pesterontests/Manifest.tests.ps1with a cleared environment —10 passed / 0 failed, so the guard does not break out-of-build runs
CI / Run Tests (Windows PowerShell 5.1)— the onething that could not be verified locally, since the spike ran on pwsh 7.6.5/Windows only
and 5.1 is a supported v1.0.0 floor
(
default.ps1auto-detection — we pass-buildFileexplicitly; thepsake.ps1/psake.cmdlaunchers — we use
Import-Module+Invoke-psake; .NET Framework < 4.0 and the$frameworkglobal — unused)Each local run used an isolated module root prepended to
PSModulePathso exactly one psakeversion was resolvable — verified for
Start-Jobchildren too, sincebuild.tests.ps1andIBTasks.tests.ps1spawn child builds.To reproduce the failure this fixes, revert
tests/Manifest.tests.ps1and run the suite underpsake 5.x:
Manifest.tests.ps1fails as a container and the count drops to 418.Breaking Changes
None. The consumer-facing surface —
RequiredModules, task names, task dependencies, and the$PSBPreferencecontract — is untouched.Reviewer notes
and then removed once we settled that this change is not user-facing. The net diff is the two
files above; the intermediate history is not worth keeping.
5.0.4. The psake-4 result above was measured locally, not in CI. Continuously testing that
claim needs a side-by-side matrix like
requirements.pester-matrix.psd1. Not added here — itis scope beyond psake 5.x migration: bump the pin to 5.0.4 and record the behavior change #161, and it is raised on [Tracking] PowerShellBuild v1.0.0 roadmap #120 as open fog rather than decided inside this PR.
Spike evidence: #155. Part of #120.