Description
Summary
ModuleBuilder 3.2.0 (released 2026-05-11) introduces two regressions that block consumers that previously worked on v3.1.7 / v3.1.8:
- Windows PowerShell 5.1 cannot import the module at all — the built
ModuleBuilder.psm1uses PowerShell 7-only syntax. Build-Modulenow fails on PowerShell 7+ when the source manifest does not contain an uncommentedAliasesToExport— this used to be optional.
Bug 1: Parse errors on Windows PowerShell 5.1
Import-Module ModuleBuilder fails before any user code runs:
At ...\ModuleBuilder\3.2.0\ModuleBuilder.psm1:1003 char:81
+ ... "Add-Parameter $($InputObject.Extent.File -ne "scriptblock" ? $InputO ...
Unexpected token '?' in expression or statement.
At ...\ModuleBuilder\3.2.0\ModuleBuilder.psm1:1858 char:9
+ | Where-Object { $_.OutputType.Name -eq "TextReplacement" -or ...
An empty pipe element is not allowed.
Root causes in the shipped .psm1:
- Line 1003: ternary operator
? :(PowerShell 7+ only) - Line 1858: pipe-leading whitespace / multi-line pipeline starting with
|(PowerShell 7+ only)
This is a regression of the same class as #135 / fixed in #136 — PS 5.1 parse errors caused by newer-syntax constructs in code paths that PS 5.1 has to parse at module-load time.
Bug 2: AliasesToExport now mandatory on PowerShell 7+
Even where the module imports successfully (i.e. on PS 7), Build-Module now rejects source manifests that have AliasesToExport commented out:
Get-Metadata: Can't find 'AliasesToExport' in <source>\<Module>.psd1
The field was optional in v3.1.x. It is unclear from the changelog whether this is intentional (in which case it is a breaking change that should be documented and major-version-bumped) or an unintended side-effect.
Repro
Install-Module ModuleBuilder -RequiredVersion 3.2.0- On Windows PowerShell 5.1:
Import-Module ModuleBuilder→ parse error. - On PowerShell 7+ with any source manifest that has
# AliasesToExport = @()commented out:Build-Module→Get-Metadataerror.
Environment
- ModuleBuilder: 3.2.0 (PSGallery, published 2026-05-11)
- PowerShell: 5.1 (Windows PowerShell) and 7.4 / 7.6 (pwsh)
- Last known-good version: 3.1.9
Workaround
Pin to < 3.2.0:
Install-Module ModuleBuilder -MaximumVersion 3.1.9 -Scope CurrentUserSuggestion
Given #135 / #136 covered the same class of issue, a CI job that runs Import-Module on Windows PowerShell 5.1 (e.g. on windows-latest with shell: powershell) would catch this regression at PR time.
Activity
gaelcolas commentedon May 15, 2026
Ah yeah, I've seen this as well.
https://synedgy.visualstudio.com/Sampler/_build/results?buildId=2616&view=logs&j=8c8f7aa2-29f0-52bf-e05a-69721ceff04c&t=8fa1b38b-945c-5f20-0560-58c4b8d0b962&l=208
fixing #140 where code is incompatible with Windows PowerShell
Fixing #140 where code is incompatible with Windows PowerShell
Jaykul commentedon May 16, 2026
I thought we are testing on Windows PowerShell. I guess it must be testing in pwsh on Windows.
Jaykul commentedon May 20, 2026
Fixed in #142
Jaykul commentedon Jun 12, 2026
I believe we finally shipped a version that not only patches this, but has a proper dependency in the nuspec 😊