Skip to content

Forward-port SCI binding fix + verify-binding-redirects.ps1 to rel/18.6#15722

Open
nohwnd wants to merge 7 commits intomicrosoft:rel/18.6from
nohwnd:forward-port-sci-rel-18.6
Open

Forward-port SCI binding fix + verify-binding-redirects.ps1 to rel/18.6#15722
nohwnd wants to merge 7 commits intomicrosoft:rel/18.6from
nohwnd:forward-port-sci-rel-18.6

Conversation

@nohwnd
Copy link
Copy Markdown
Member

@nohwnd nohwnd commented Apr 23, 2026

Forward-ports #15720 (SCI 8.0.0 binding fix) and #15719 (verify-binding-redirects.ps1) to rel/18.6.

SCI fix cherry-picked clean from bb8913d. Binding-redirect verification script wasn't on rel/18.6 yet so #15719 (f2044ac) is ported along with it.

All 18.6/18.7/18.8 preview packages on the test-tools feed reproduce the System.Collections.Immutable 8.0.0.0 FileLoadException in Azure DevOps VSTest@2 DTA distributed runs - see nohwnd/tptest smoke pipeline. 18.5.1 with #15720 applied fixes both @2 and @3.

nohwnd and others added 7 commits April 23, 2026 18:37
Ports the binding redirect verification script (and verify-nupkgs.ps1 wiring)
from main/rel/18.7. Running against the shipped Microsoft.TestPlatform.*.nupkg
layout, the script validates that the newVersion of each assembly binding
redirect in vstest.console, testhost.x86, and datacollector app.config files
matches the actual assembly version of the DLL shipped next to the exe.

In CI it fails with instructions; locally it auto-fixes the app.config files.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…18.5) (microsoft#15720)

* Add DtaLikeHost repro for SCI 8.0.0 binding mismatch

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>

* Fix SCI 8.0.0 binding mismatch in Common.dll; add DTA integration test

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>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- GetIsolatedTestAsset requires targetFramework argument (pass net472)
- Use Assert.Contains instead of StringAssert.Contains (MSTEST0046)
- Use string.Empty instead of null for ExecuteApplication args

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Move System.Collections.Immutable PackageReference from CoreUtilities and ObjectModel csprojs into the root Directory.Build.targets so every non-test product project that targets .NETFramework compiles and ships with a consistent SCI version (the one from Versions.props).

Required on 18.6/18.7/main because SCI was bumped to 9.0.11 (AssemblyVersion 9.0.0.11). With the fix only on the two csprojs, Common.dll would reference SCI 9.0.0.11 while sibling DLLs in the VSIX-style Common7/IDE/Extensions/TestPlatform/Extensions/ layout (TestHostRuntimeProvider.dll, etc.) still referenced an older SCI version, causing FileLoadException in hosts without a wide-enough binding redirect.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Package projects (Microsoft.TestPlatform, Microsoft.TestPlatform.CLI, Microsoft.TestPlatform.Portable) already declare System.Collections.Immutable with GeneratePathProperty for packaging; re-adding it centrally triggers NU1504 duplicate PackageReference error. Gate the central ItemGroup on the project not living under src/package/.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…2 layout

The Microsoft.TestPlatform package was copying System.Collections.Immutable from the SCI package's lib/netstandard2.0 folder (AssemblyVersion 9.0.0.0) into its tools/net462 layout. After the SCI PackageReference fix, Common.dll and sibling DLLs are compiled with a 9.0.0.11 metadata reference (the AssemblyVersion of the net462-specific build of SCI 9.0.11), so the shipped netstandard2.0 SCI triggers FileLoadException 'manifest definition does not match the assembly reference' when extensions are loaded from the VSIX-style Common7/IDE/Extensions/TestPlatform/Extensions/ folder.

Copy from lib/net462 instead so the shipped SCI AssemblyVersion matches the compiled references. The CopyFiles target is already gated on NetFrameworkRunnerTargetFramework so this only affects the net462 portion of the package.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
System.Collections.Immutable 9.0.11's net462 AssemblyVersion is 9.0.0.11, not 9.0.0.0. The app.config redirects in vstest.console.exe, testhost.x86.exe, and datacollector.exe had newVersion=9.0.0.0 which caused Verify-BindingRedirects to fail.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

1 participant