Skip to content

Reference System.Management.Automation from the oldest supported PowerShell - #3021

Merged
nohwnd merged 2 commits into
mainfrom
fix-3013-sma-reference-baseline
Sep 5, 2026
Merged

Reference System.Management.Automation from the oldest supported PowerShell#3021
nohwnd merged 2 commits into
mainfrom
fix-3013-sma-reference-baseline

Conversation

@nohwnd

@nohwnd nohwnd commented Sep 5, 2026

Copy link
Copy Markdown
Member

Fix #3013

The net8.0 assembly referenced System.Management.Automation 7.4.5.0. .NET resolves an assembly reference forward to a newer version, but never backward to an older one, so on PowerShell 7.4.0 to 7.4.5 that reference cannot be satisfied and the import fails.

The error does not say any of that:

Cannot convert "PesterConfigurationDeserializer" from String to Type

Update-TypeData -TypeConverter 'PesterConfigurationDeserializer' resolves the type from a string, and that is the first type we touch that inherits from something in System.Management.Automation (PSTypeConverter). PesterConfiguration derives from System.Object, so it still resolves and the version guard in Pester.psm1 passes, which is why the import gets that far before it breaks.

This affected 6.0.0 as well, both releases shipped with 7.4.5.0.

Why 7.4.0

We ship Pester.dll and nothing else. System.Management.Automation comes from the host PowerShell, this is only a compile time reference, so it should sit at the baseline of the oldest PowerShell line we support and let the runtime supply anything newer. That is how it used to be here, before the net8 move this referenced 7.1.7, which was older than 7.2.0.

7.4.0 is not itself a supported PowerShell. Microsoft only supports the latest patch of a line, so the 7.4 line is supported until 10-Nov-2026 but the supported patch is 7.4.19. Referencing the baseline anyway means Pester still loads for people who are behind on their updates. That is deliberate. Whether their PowerShell is patched is their decision, a compile time reference is the wrong place to enforce it, and an unreadable load error is a bad way to enforce anything.

The advisory the bump was avoiding

Versions older than 7.4.6 have security vulnerabilities. was the reason given, and it was a real one, just not in System.Management.Automation itself. 7.4.0 pulls in System.Formats.Asn1 8.0.0 transitively, which has CVE-2024-38095 (high, DoS parsing X.509). With NuGetAuditMode=all:

warning NU1903: Package 'System.Formats.Asn1' 8.0.0 has a known high severity vulnerability

We do not ship that assembly either, so it never reaches anyone through Pester, but there is no reason to keep it in the build graph. Pinned to 8.0.1, which is the patched version. Audit is clean and the shipped Pester.dll does not reference System.Formats.Asn1 at all.

Verification

Builds clean on net8.0 and net462, 0 warnings, 0 errors. Restore is clean under NuGetAuditMode=all -p:NuGetAuditLevel=low. Emitted reference:

System.Management.Automation 7.4.0.0

Added a test in tst/Pester.Tests.ps1 that reads the reference off the loaded assembly. It fails against 6.0.0 and 6.1.0, which is the point, nothing caught this twice in a row.

I could not run a real 7.4.0 to confirm the import, my machine is on 7.5.5. If CI has a 7.4.0 job that would close it properly.

🤖

…rShell

The net8.0 assembly referenced System.Management.Automation 7.4.5.0, because the
package reference was bumped to 7.4.6 to avoid a security advisory. .NET resolves an
assembly reference forward to a newer version, but never backward to an older one, so
on PowerShell 7.4.0 to 7.4.5 that reference cannot be satisfied and the import fails.

The error does not say that. Import fails on the first type that inherits from a type
in System.Management.Automation, which is PesterConfigurationDeserializer, and
Update-TypeData reports 'Cannot convert "PesterConfigurationDeserializer" from String
to Type'. PesterConfiguration itself derives from System.Object, so it still resolves
and the existing version guard in Pester.psm1 passes.

The advisory does not apply to this reference. We ship Pester.dll and nothing else,
System.Management.Automation comes from the host PowerShell, so raising the number
here patches nothing for anyone, it only drops support for the patch releases below
it. Put the reasoning in the csproj next to the reference so it does not get bumped
again.

Added a test that reads the reference off the loaded assembly. 6.0.0 and 6.1.0 both
shipped with 7.4.5.0 and nothing caught it.

Fix #3013

🤖
@nohwnd
nohwnd enabled auto-merge (squash) September 5, 2026 07:55
The 7.4.6 bump was avoiding CVE-2024-38095 in System.Formats.Asn1, which
System.Management.Automation 7.4.0 pulls in transitively at 8.0.0. Restoring 7.4.0
brings that package back, so pin System.Formats.Asn1 to 8.0.1, which is the patched
version. NuGet audit is clean again, and it does not change what we ship, the built
Pester.dll does not reference System.Formats.Asn1 at all.

Also fix the wording. Microsoft only supports the latest patch of a line, so 7.4.0
itself is not a supported PowerShell, 7.4.19 is. 7.4.0 is the baseline of the 7.4 line
and that is why we reference it, not because it is supported. Referencing it means
Pester still loads for people who are behind on their PowerShell updates, which is
deliberate, and does not ship them anything vulnerable.

🤖
@nohwnd
nohwnd merged commit 9d082f7 into main Sep 5, 2026
20 checks passed
@nohwnd
nohwnd deleted the fix-3013-sma-reference-baseline branch September 5, 2026 08:15
nohwnd added a commit that referenced this pull request Sep 5, 2026
* Write the 6.2.0-alpha2 release notes pass

Covers the four user visible pull requests merged since alpha1. #3025 and #3021
were already in the file.

Should-BeFasterThan and Should-BeSlowerThan rejecting what they cannot measure is
a behavior change, not a fix. A test that passed on a string or an int was not
asserting anything and it fails now.

🤖

* Bump the manifest to alpha2

The notes heading moved to 6.2.0-alpha2 but src/Pester.psd1 still said alpha1, so
the built module would have published as 6.2.0-alpha1 again. Prerelease and the
ReleaseNotes link follow the heading. ModuleVersion and RequiredAssemblyVersion stay
at 6.2.0, only the prerelease label changes.
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.

Pester 6.1.0 fails to import on PowerShell 7.4.0 Linux runner: Cannot convert "PesterConfigurationDeserializer" from String to Type

1 participant