Skip to content

PowerShell 7.5 ASP.NET Core 8 Microsoft.Extensions.* assemblies while running on .NET 9 #26630

@mdaneri

Description

@mdaneri

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version.
  • Search the existing issues.
  • Refer to the FAQ.
  • Refer to Differences between Windows PowerShell 5.1 and PowerShell.

Summary

PowerShell 7.5 runs on .NET 9, but loads ASP.NET Core 8 LTS Microsoft.Extensions.* assemblies
(e.g. Microsoft.Extensions.ObjectPool.dll) from the PowerShell installation directory.

This version mismatch causes in-process dependency conflicts for PowerShell modules or libraries targeting net9.0
that depend on newer Microsoft.Extensions.* APIs or behaviors.

Because PowerShell loads modules into a single AssemblyLoadContext, the vendored ASP.NET Core 8 assemblies take
precedence and prevent net9.0 libraries from loading their expected dependencies.


Steps to reproduce

  1. Install the latest released PowerShell 7.5.x.
  2. Start a clean PowerShell session.
  3. Verify the runtime version:
[System.Runtime.InteropServices.RuntimeInformation]::FrameworkDescription
  1. Force-load Microsoft.Extensions.ObjectPool:
$null = [Microsoft.Extensions.ObjectPool.DefaultObjectPoolProvider]

$asm = [AppDomain]::CurrentDomain.GetAssemblies() |
  Where-Object { $_.GetName().Name -eq 'Microsoft.Extensions.ObjectPool' } |
  Select-Object -First 1

$asm.Location
  1. Inspect the file metadata:
(Get-Item $asm.Location).VersionInfo |
  Select-Object FileVersion, ProductVersion, ProductName

Expected behavior

When PowerShell reports that it is running on .NET 9, modules targeting net9.0 should be able to rely on
compatible Microsoft.Extensions.* assemblies, or there should be clear guidance and tooling support for managing
the version alignment.


Actual behavior

PowerShell 7.5 runs on .NET 9, but loads ASP.NET Core 8 LTS Microsoft.Extensions.* assemblies from its own
installation directory.

This leads to:

  • TypeLoadException
  • MissingMethodException
  • subtle runtime incompatibilities

for modules built against Microsoft.Extensions.* 9.x APIs.


Error details

TypeLoadException / MissingMethodException when loading net9.0 libraries
that depend on newer Microsoft.Extensions.* APIs.

Environment data

Name                           Value
----                           -----
PSVersion                      7.5.4
PSEdition                      Core
GitCommitId                    7.5.4
OS                             Microsoft Windows 10.0.26200
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

.NET Runtime                   9.0.10
Vendored Assembly              Microsoft.Extensions.ObjectPool.dll
AssemblyVersion                8.0.0.0
FileVersion                    8.0.2125.47515
ProductVersion                 8.0.21
ProductName                    Microsoft ASP.NET Core
Assembly Location              C:\Program Files\PowerShell\7.5

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Maintainers-Buildspecific to affecting the buildNeeds-TriageThe issue is new and needs to be triaged by a work group.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions