Skip to content

GetTFM doesn't map PowerShell 7.6+ to net10.0 #123

Closed

Description

@jamescrosswell

On PowerShell 7.6 (which runs on .NET 10), `GetTFM` in `Get-SentryAssembliesDirectory.ps1` has no branch for 7.6, so it falls through to the `>= '7.5'` branch and returns `net9.0`. The module loads the .NET 9-targeted `Sentry.dll` into a .NET 10 runtime, which triggers `Add-Type` to print:

```
Add-Type: error CS1701: Assuming assembly reference 'System.Runtime, Version=9.0.0.0, ...' used by 'Sentry' matches identity 'System.Runtime, Version=10.0.0.0, ...' of 'System.Runtime', you may need to supply runtime policy
Add-Type: Cannot add type. Compilation errors occurred.
```

CS1701 is officially a warning, but `Add-Type` on pwsh 7.6 / .NET 10 surfaces it as a fatal compilation error. The downstream consequence is that the C# `SentryEventProcessor_` base type never gets created, which then cascades into all the `ParserError: Unable to find type [SentryEventProcessor]` noise on module import (tracked separately in #124). Colleagues on pwsh 7.5 hit the `>= '7.5' → net9.0` branch where the assembly target matches the runtime exactly, so they see neither the CS1701 nor the cascade.

Fix

Add a branch for 7.6 → `net10.0` in `GetTFM` and update the version-mapping comment block.

This depends on the bundled sentry-dotnet SDK shipping a `net10.0` build. The currently pinned 5.16.1 does not (its highest is `net9.0`); the latest Sentry 6.5.0 does. So this fix is gated on bumping the SDK — see #125 (and the Dependabot automation in #126 to keep it from drifting in the future).

Originally filed as 'silence the CS1701 warnings'; rewritten after diagnosing the real root cause.

Activity

  1. linear-code commented on May 22, 2026

    @linear-code
  2. changed the title [-]Silence CS1701 System.Runtime version warnings from Add-Type[/-] [+]Silence Add-Type CS1701 System.Runtime version warnings[/+] on May 22, 2026
  3. changed the title [-]Silence Add-Type CS1701 System.Runtime version warnings[/-] [+]GetTFM doesn't map PowerShell 7.6+ to net10.0[/+] on May 25, 2026
  4. jamescrosswell commented on May 25, 2026

    @jamescrosswell
    CollaboratorAuthor

    Closing — this isn't really independent of #125. The fix needs:

    1. Bumping sentry-dotnet to ≥ 6.0 (which introduced the net10.0 build) — already the scope of Bump sentry-dotnet SDK to add .NET 10 / PowerShell 7.6 support #125.
    2. Adding a Download -Dependency 'Sentry' -TFM 'net10.0' line to dependencies/download.ps1.
    3. Adding a >= '7.6' → 'net10.0' branch to GetTFM in Get-SentryAssembliesDirectory.ps1.

    Folding (2) and (3) into #125 as part of that work. The cosmetic CS1701/CS1702 noise (originally part of this issue's framing) is now tracked separately in #132 / PR #129 as defense-in-depth against future runtime drift.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions