Skip to content

Fix SCI binding failure in DTA hosts (main)#15724

Open
nohwnd wants to merge 15 commits intomicrosoft:mainfrom
nohwnd:forward-port-sci-main
Open

Fix SCI binding failure in DTA hosts (main)#15724
nohwnd wants to merge 15 commits intomicrosoft:mainfrom
nohwnd:forward-port-sci-main

Conversation

@nohwnd
Copy link
Copy Markdown
Member

@nohwnd nohwnd commented Apr 23, 2026

Fix DTA hosts crashing with FileLoadException on System.Collections.Immutable 8.0.0.0.

Why

SCI 9.0.11 has different assembly versions per TFM: net462 gets 9.0.0.11, netstandard2.0 gets 9.0.0.0. Product assemblies (Common.dll etc.) are netstandard2.0 and compile against SCI 8.0.0.0 (from the SRM 8.0.0 transitive dependency). The nupkg ships SCI 9.0.0.0. DTA loads Common.dll without binding redirects, asks for 8.0.0.0, finds 9.0.0.0 — crash.

Changes

  • Add explicit SCI PackageReference to CoreUtilities and ObjectModel for non-.NETCoreApp targets. This bumps all netstandard2.0 product assemblies to compile against SCI 9.0.0.0, matching the shipped DLL.
  • Extend SCI binding redirect range to 9.0.0.11 (covers the net462 assembly version).
  • Suppress MSB3277 for .NETCoreApp targets — the netstandard2.0-vs-inbox version mismatch is harmless on .NET Core.
  • Fix MSBuildWarningsAsMessages inheritance in packaging projects (was overwriting parent values).
  • Add acceptance test that validates SCI version alignment in nupkg/VSIX layouts.

Fixes #15718

Related PRs: #15722 (rel/18.6), #15723 (rel/18.7)

Copilot AI review requested due to automatic review settings April 23, 2026 16:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Forward-ports the rel/18.5 fix for the System.Collections.Immutable binding mismatch affecting Microsoft.VisualStudio.TestPlatform.Common.dll on .NET Framework hosts without binding redirects (notably Azure DevOps DTA), and adds an acceptance-test regression guard.

Changes:

  • Add explicit System.Collections.Immutable PackageReference for .NETFramework builds in CoreUtilities and ObjectModel to force consistent compile-time SCI references.
  • Add a new DtaLikeHost test asset (net472) that simulates DTA-style consumption of the shipped tools/net462 layout (no binding redirects).
  • Add new acceptance tests that run DtaLikeHost against both the nupkg tools/net462/... layout and the extracted V2.CLI VSIX layout.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/TestAssets/DtaLikeHost/Program.cs Minimal host executable that triggers FastFilter.Builder to force SCI/SRM binding at runtime.
test/TestAssets/DtaLikeHost/DtaLikeHost.csproj Builds the repro host and references shipped Common.dll/ObjectModel.dll from either nupkg tools layout or extracted VSIX layout.
test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DistributedTestAgentScenarioTests.cs New acceptance tests that build/run DtaLikeHost as a regression guard.
src/Microsoft.TestPlatform.ObjectModel/Microsoft.TestPlatform.ObjectModel.csproj Forces SCI version selection for .NETFramework builds via explicit package reference.
src/Microsoft.TestPlatform.CoreUtilities/Microsoft.TestPlatform.CoreUtilities.csproj Forces SCI version selection for .NETFramework builds via explicit package reference.

Copilot AI review requested due to automatic review settings April 24, 2026 09:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comment thread Directory.Build.targets Outdated
Copilot AI review requested due to automatic review settings April 24, 2026 11:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Comment thread test/TestAssets/DtaLikeHost/Program.cs
Comment thread src/package/Microsoft.TestPlatform/Microsoft.TestPlatform.csproj Outdated
Copilot AI review requested due to automatic review settings April 24, 2026 12:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Comment thread test/TestAssets/DtaLikeHost/DtaLikeHost.csproj Outdated
Copilot AI review requested due to automatic review settings April 24, 2026 14:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings April 27, 2026 13:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.

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.

- Directory.Build.targets: ExcludeAssets=compile on SCI PackageReference +
  explicit Reference to netstandard2.0 DLL for .NET Framework product projects
- Extend binding redirect oldVersion to cover 9.0.0.11
- Add DtaLikeHost test asset and acceptance test

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nohwnd nohwnd force-pushed the forward-port-sci-main branch from 624e723 to e6d27b1 Compare April 27, 2026 15:36
@nohwnd
Copy link
Copy Markdown
Member Author

nohwnd commented Apr 27, 2026

wait we need to ship nestanardd, fixing

@nohwnd nohwnd closed this Apr 27, 2026
@nohwnd nohwnd reopened this Apr 27, 2026
nohwnd and others added 3 commits April 28, 2026 16:32
Add explicit System.Collections.Immutable PackageReference to CoreUtilities
and ObjectModel for non-.NETCoreApp targets (netstandard2.0 + .NETFramework).
This ensures all product assemblies compile against SCI 9.0.0.0 (the
netstandard2.0 assembly version), matching the SCI DLL shipped in nupkgs.

Extend SCI binding redirect oldVersion range to 9.0.0.11 in app.configs
to cover the net462 assembly version from SCI 9.0.11.

Suppress MSB3277 for .NETCoreApp targets in Directory.Build.targets since
the netstandard2.0 SCI 9.0.0.0 reference is harmless on .NET Core (the
runtime loads whatever version is available regardless of the reference).

Fix MSBuildWarningsAsMessages inheritance in packaging projects that was
overwriting parent values instead of appending.

Add acceptance test that validates SCI version alignment in nupkg/VSIX
layouts using PEReader/MetadataReader.

Fixes microsoft#15718

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

# Conflicts:
#	test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DistributedTestAgentScenarioTests.cs
Copilot AI review requested due to automatic review settings April 28, 2026 14:34
@nohwnd nohwnd changed the title Forward-port SCI binding fix to main Fix SCI binding failure in DTA hosts (main) Apr 28, 2026
nohwnd and others added 11 commits April 28, 2026 16:53
The merge with the old PR branch brought back the ExcludeAssets/HintPath
workaround that was replaced by the simpler PackageReference approach.

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

- Bump SystemCollectionsImmutablePackageVersion to 10.0.0
- Update binding redirects to 10.0.0.0
- Restore DTA acceptance test with correct DLL name

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

verify-binding-redirects auto-corrected:
- System.Memory: 4.0.1.2 -> 4.0.5.0 (Release build ships newer AV)
- System.Runtime.CompilerServices.Unsafe: 6.0.0.0 -> 6.0.3.0

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Previous count of 484 was from a dirty build with stale artifacts.
Clean Release build produces 389 files, matching CI.

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

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

Add DtaLikeHost test asset with SCI 10.0.0 transitive dep copies
(System.Memory, System.Buffers, System.Runtime.CompilerServices.Unsafe).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
System.Buffers, System.Memory, and System.Numerics.Vectors are now
netframework-targeted (transitive deps of SCI 10.0.0 netstandard2.0).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nohwnd nohwnd enabled auto-merge (squash) May 5, 2026 09:51
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.

18.5.0 introduced an error Could not load file or assembly 'System.Collections.Immutable, Version=8.0.0.0

2 participants