Fix SCI binding failure in DTA hosts (rel/18.6) by nohwnd · Pull Request #15722 · microsoft/vstest (original) (raw)

@nohwnd

Force .NET Framework product projects to compile against the netstandard2.0 build of System.Collections.Immutable (AssemblyVersion 9.0.0.0) instead of the net462 build (AssemblyVersion 9.0.0.11). SCI 9.0.11 introduced an AV divergence between the two TFMs; the nupkg ships the netstandard2.0 DLL, so compiled metadata must reference 9.0.0.0 for consumers without binding redirects (e.g. Azure DevOps Distributed Test Agent) to avoid FileLoadException.

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

@nohwnd

Add explicit System.Collections.Immutable PackageReference to CoreUtilities and ObjectModel for non-.NETCoreApp targets. This ensures product assemblies compile against SCI 9.0.0.0, matching the shipped DLL.

Extend SCI binding redirect to cover net462 AV 9.0.0.11. Suppress MSB3277 for .NETCoreApp targets. Fix MSBuildWarningsAsMessages inheritance in packaging projects.

Fixes microsoft#15718

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

@nohwnd

…x-sci-18.6

Conflicts:

test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DistributedTestAgentScenarioTests.cs

@nohwnd nohwnd changed the titleForward-port SCI binding fix + verify-binding-redirects.ps1 to rel/18.6 Fix SCI binding failure in DTA hosts (rel/18.6)

Apr 28, 2026

@nohwnd

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

@nohwnd

The previous condition '!= .NETCoreApp' included netstandard2.0, which made netstandard2.0 assemblies reference SCI 9.0.0.0. This breaks on .NET 8 where the shared framework only has SCI 8.0.0.0.

Change to '== .NETFramework' so only net462 builds get the explicit SCI reference (covered by binding redirects), while netstandard2.0 keeps SCI 8.0.0.0 from the SRM transitive dependency.

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

@nohwnd

The DTA scenario (loading SCI without binding redirects) cannot be fully fixed with SCI 9.0.11 due to assembly version divergence between net462 (9.0.0.11) and netstandard2.0 (9.0.0.0). This will be tracked in a separate issue.

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

@nohwnd

SCI 9.0.11 has different assembly versions for net462 (9.0.0.11) vs netstandard2.0 (9.0.0.0). DTA hosts without binding redirects need exact version match. SCI 10.0.0 has AV 10.0.0.0 for all TFMs.

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

@nohwnd

…d vstest.console

SCI 10.0.0 introduces a transitive dependency on System.Memory for net462. In Release builds, the shipped System.Memory.dll has assembly version 4.0.5.0, but the MSTest adapter loads against 4.0.1.2. Without a binding redirect, the CLR cannot resolve the version mismatch.

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

@nohwnd

System.Memory 4.6.3 (transitive from SCI 10.0.0) depends on System.Buffers. In Release builds, System.Buffers.dll has AV 4.0.5.0, but MSTest adapter loads against 4.0.3.0. Without a redirect, the CLR cannot resolve the mismatch.

Also fix System.Text.Json redirect in vstest.console to point to 6.0.0.0 (the actual shipped DLL version) instead of 6.0.0.11.

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

@nohwnd

…tion

The test loads net462 extension DLLs which reference SCI 10.0.0.0, but the .NET 8 test host runtime only ships SCI 8.0.0.0. Assembly.LoadFrom cannot resolve the version mismatch. Use a custom AssemblyLoadContext that resolves dependencies from the extensions directory.

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

@nohwnd

The actual System.Runtime.CompilerServices.Unsafe DLL shipped in the nupkg has assembly version 6.0.3.0 (from SCI 10.0.0 transitive deps), but the binding redirect was still targeting 6.0.0.0, causing FileLoadException in testhost and other processes.

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

@nohwnd

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

@nohwnd

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

@nohwnd

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

@nohwnd

Replace the static PE metadata check in DistributedTestAgentScenarioTests with the original DtaLikeHost approach from rel/18.5: build and run a net472 exe that loads Common.dll without binding redirects.

Update DtaLikeHost.csproj to copy SCI 10.0.0 transitive deps (System.Memory, System.Buffers, System.Runtime.CompilerServices.Unsafe) alongside the existing SCI and SRM copies.

Revert the custom AssemblyLoadContext hack from DiscoveryTests.cs — not needed since SCI resolves correctly from the extensions directory.

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

@nohwnd

The test loads net462 extensions via Assembly.LoadFrom in a .NET 9 host. SCI 10.0.0.0 conflicts with the runtime's 9.0.0.0 — this is not a real production scenario since vstest.console ships its own SCI in deps.json. The actual customer scenario (DTA/net48, no binding redirects) is covered by DistributedTestAgentScenarioTests/DtaLikeHost.

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

JanKrivanek

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 }})