Running any sample on PowerShell Core (.NET 8+) prints five copies of:
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.
The warnings are harmless — .NET binds successfully and the module works — but they're noisy and look alarming to anyone running the samples for the first time.
Analysis
The warnings come from the Add-Type call in modules/Sentry/Sentry.psm1 that compiles SentryEventProcessor.cs with -ReferencedAssemblies $sentryDllPath. Roslyn compiles against Sentry.dll, whose metadata references System.Runtime at a version that differs from the version loaded by the host process (e.g. PowerShell on .NET 10 loads System.Runtime 10.0.0.0, while Sentry.dll for net8.0/net9.0 references 9.0.0.0). Each mismatched reference emits one CS1701, hence "five copies".
Solution
Pass -CompilerOptions '/nowarn:CS1701;CS1702' (or equivalent) to the Add-Type call in Sentry.psm1 so Roslyn suppresses the harmless binding-redirect warnings while still surfacing real compile errors.
Reproduces with any sample, e.g. pwsh ./samples/locate-city.ps1 Paris.
Running any sample on PowerShell Core (.NET 8+) prints five copies of:
The warnings are harmless — .NET binds successfully and the module works — but they're noisy and look alarming to anyone running the samples for the first time.
Analysis
The warnings come from the
Add-Typecall inmodules/Sentry/Sentry.psm1that compilesSentryEventProcessor.cswith-ReferencedAssemblies $sentryDllPath. Roslyn compiles againstSentry.dll, whose metadata referencesSystem.Runtimeat a version that differs from the version loaded by the host process (e.g. PowerShell on .NET 10 loadsSystem.Runtime10.0.0.0, whileSentry.dllfornet8.0/net9.0references 9.0.0.0). Each mismatched reference emits one CS1701, hence "five copies".Solution
Pass
-CompilerOptions '/nowarn:CS1701;CS1702'(or equivalent) to theAdd-Typecall inSentry.psm1so Roslyn suppresses the harmless binding-redirect warnings while still surfacing real compile errors.Reproduces with any sample, e.g.
pwsh ./samples/locate-city.ps1 Paris.