Fix System.Collections.Immutable binding mismatch in Common.dll (rel/18.5) by nohwnd · Pull Request #15720 · microsoft/vstest (original) (raw)

and others added 2 commits

April 22, 2026 22:37

@nohwnd

Minimal net472 console app that consumes Microsoft.TestPlatform 18.5.0 package the way Azure DevOps' Distributed Test Agent does: references Common.dll from the package's tools/net462/.../TestPlatform layout and runs without any binding redirects in app.config.

Constructs a FilterExpressionWrapper with a simple equality filter, which triggers FastFilter.Builder (uses ImmutableDictionary) and forces the CLR to resolve System.Collections.Immutable.

Repros the FileLoadException reported by customers: Common.dll metadata requires System.Collections.Immutable v8.0.0.0, but the package ships v9.0.0.0 next to it.

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

@nohwnd

Common.dll (net462, shipped in the Microsoft.TestPlatform nupkg and the V2.CLI VSIX) used to have a compiled metadata ref to System.Collections.Immutable 8.0.0.0 while we ship SCI 9.0.0.0 next to it. Hosts without the '1.0.0.0-9.0.0.0 -> 9.0.0.0' binding redirect (Azure DevOps' DTAExecutionHost, some VS components) FileLoadException the moment FastFilter.Builder touches SCI.

Fix: add an explicit System.Collections.Immutable PackageReference to CoreUtilities and ObjectModel, gated on TargetFrameworkIdentifier == .NETFramework, so the compile-time SCI ref in the net462 Common.dll is 9.0.0. This only affects the net462 build (the one we ship next to SCI 9.0.0), keeps the netstandard2.0 ref on 8.0.0 to avoid breaking net8.0 datacollector, and touches zero app.config redirects - no VSIX/VS servicing needed.

Turn the DtaLikeHost repro into an automated acceptance test with two variants: one against the nupkg's tools/net462/... layout (as DTA consumes it), one against the flat V2.CLI VSIX layout (as VS consumes it). Both load Common.dll with no binding redirects and call FilterExpressionWrapper; before the fix both fail with the customer's FileLoadException.

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

This was referenced

Apr 23, 2026

This was referenced

Apr 28, 2026

This was referenced

Jun 11, 2026

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})