Sitelet https://github.com/microsoft/vstest/commit/778909789acae5b87b753b4daea984e4b23a1e4c
Skip to content

Commit 7789097

Browse files
nohwndCopilot
andauthored
Fix SCI binding failure in DTA hosts (rel/18.6) (#15722)
* Fix SCI binding for DTA-like hosts without binding redirects 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> * Fix SCI binding failure in DTA hosts without binding redirects 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 #15718 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Remove old ExcludeAssets remnant, fix corrupted app.config XML Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix SCI condition to .NETFramework only 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> * Remove DTA acceptance test 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> * Bump SCI to 10.0.0 to fix AV divergence 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 SystemCollectionsImmutableVersion 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> * Add System.Memory binding redirect to testhost.x86, datacollector, and 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> * Add System.Buffers binding redirect and fix System.Text.Json redirect 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> * Fix TypesToLoadAttributeTests to use custom ALC for dependency resolution 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> * Fix Unsafe binding redirect version 6.0.0.0 -> 6.0.3.0 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> * Retrigger CI - pool may have recovered Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Retrigger CI (pool stalled 24h+) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Retrigger CI (pool stalled 36h+) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Use DtaLikeHost exe for SCI binding test, revert ALC hack 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> * Skip TypesToLoadAttributeTests on .NET 9 branches 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> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 18d238e commit 7789097

14 files changed

Lines changed: 303 additions & 13 deletions

File tree

‎Directory.Build.targets‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,18 @@
44
<!-- Temporary workaround for Arcade issue in net9-preview5 -->
55
<_NetFrameworkHostedCompilersVersion Condition="'$(_NetFrameworkHostedCompilersVersion)' == ''">4.11.0-3.24280.3</_NetFrameworkHostedCompilersVersion>
66
</PropertyGroup>
7-
7+
8+
<PropertyGroup>
9+
<DefineConstants Condition="'$(IsFilterSourcePackage)' != 'true'">$(DefineConstants);IS_VSTEST_REPO</DefineConstants>
10+
<!--
11+
MSB3277: netstandard2.0 product assemblies reference SCI 9.0.0.0 (from the explicit
12+
PackageReference needed for the DTA scenario — see issue #15718), but .NETCoreApp
13+
targets have inbox SCI 8.0.0.0. This is harmless: .NET Core assembly loading is
14+
version-tolerant and will load the available version regardless of the reference.
15+
-->
16+
<MSBuildWarningsAsMessages Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">$(MSBuildWarningsAsMessages);MSB3277</MSBuildWarningsAsMessages>
17+
</PropertyGroup>
18+
819
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
920
<!-- Override the version of imported package to avoid infinite restore loop in VisualStudio, https://github.com/dotnet/arcade/issues/16228 -->
1021
<ItemGroup>

‎eng/Versions.props‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
<_MicrosoftVSSDKBuildToolsVersion_>17.14.2119</_MicrosoftVSSDKBuildToolsVersion_>
7171
<MicrosoftWin32RegistryVersion>5.0.0</MicrosoftWin32RegistryVersion>
7272
<NewtonsoftJsonVersion>13.0.3</NewtonsoftJsonVersion>
73-
<SystemCollectionsImmutableVersion>9.0.11</SystemCollectionsImmutableVersion>
73+
<SystemCollectionsImmutableVersion>10.0.0</SystemCollectionsImmutableVersion>
7474
<SystemMemoryVersion>4.5.5</SystemMemoryVersion>
7575
<SystemReflectionMetadataVersion>8.0.0</SystemReflectionMetadataVersion>
7676
<TestPlatformExternalsVersion>18.0.0-preview-1-10911-061</TestPlatformExternalsVersion>

‎src/Microsoft.TestPlatform.CoreUtilities/Microsoft.TestPlatform.CoreUtilities.csproj‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<ItemGroup>
2020
<PackageReference Include="Microsoft.Win32.Registry" Version="$(MicrosoftWin32RegistryVersion)" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
2121
<PackageReference Include="System.Reflection.Metadata" Version="$(SystemReflectionMetadataVersion)" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'" />
22+
<PackageReference Include="System.Collections.Immutable" Version="$(SystemCollectionsImmutableVersion)" Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'" />
2223
</ItemGroup>
2324

2425
<ItemGroup>

‎src/Microsoft.TestPlatform.ObjectModel/Microsoft.TestPlatform.ObjectModel.csproj‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
<PackageReference Include="System.ValueTuple" Version="4.5.0"
3838
Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net48')) != 'true' and '$(TargetFrameworkIdentifier)' == '.NETFramework'" />
3939
<PackageReference Include="System.Reflection.Metadata" Version="$(SystemReflectionMetadataVersion)" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'" />
40+
<PackageReference Include="System.Collections.Immutable" Version="$(SystemCollectionsImmutableVersion)" Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'" />
4041
</ItemGroup>
4142

4243
<ItemGroup>

‎src/datacollector/app.config‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,21 @@
2222
</dependentAssembly>
2323
<dependentAssembly>
2424
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
25-
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
25+
<bindingRedirect oldVersion="0.0.0.0-6.0.3.0" newVersion="6.0.3.0" />
2626
</dependentAssembly>
27+
<dependentAssembly>
28+
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
29+
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
30+
</dependentAssembly>
31+
32+
<dependentAssembly>
33+
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
34+
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
35+
</dependentAssembly>
36+
2737
<dependentAssembly>
2838
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
29-
<bindingRedirect oldVersion="1.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
39+
<bindingRedirect oldVersion="1.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
3040
</dependentAssembly>
3141
<dependentAssembly>
3242
<assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />

‎src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.csproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
Sometimes NU1702 is not suppressed correctly, so force reducing severity of the warning.
3838
See https://github.com/NuGet/Home/issues/9147
3939
-->
40-
<MSBuildWarningsAsMessages>NU1702</MSBuildWarningsAsMessages>
40+
<MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);NU1702</MSBuildWarningsAsMessages>
4141
</PropertyGroup>
4242

4343
<!-- runner and runner dependencies -->

‎src/package/Microsoft.TestPlatform.Portable/Microsoft.TestPlatform.Portable.csproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Sometimes NU1702 is not suppressed correctly, so force reducing severity of the warning.
1313
See https://github.com/NuGet/Home/issues/9147
1414
-->
15-
<MSBuildWarningsAsMessages>NU1702</MSBuildWarningsAsMessages>
15+
<MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);NU1702</MSBuildWarningsAsMessages>
1616
</PropertyGroup>
1717

1818
<PropertyGroup>

‎src/package/Microsoft.TestPlatform/Microsoft.TestPlatform.csproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
Sometimes NU1702 is not suppressed correctly, so force reducing severity of the warning.
1212
See https://github.com/NuGet/Home/issues/9147
1313
-->
14-
<MSBuildWarningsAsMessages>NU1702;NETSDK1023</MSBuildWarningsAsMessages>
14+
<MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);NU1702;NETSDK1023</MSBuildWarningsAsMessages>
1515
</PropertyGroup>
1616

1717
<PropertyGroup>

‎src/testhost.x86/app.config‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,21 @@
3535
</dependentAssembly>
3636
<dependentAssembly>
3737
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
38-
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
38+
<bindingRedirect oldVersion="0.0.0.0-6.0.3.0" newVersion="6.0.3.0" />
3939
</dependentAssembly>
40+
<dependentAssembly>
41+
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
42+
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
43+
</dependentAssembly>
44+
45+
<dependentAssembly>
46+
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
47+
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
48+
</dependentAssembly>
49+
4050
<dependentAssembly>
4151
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
42-
<bindingRedirect oldVersion="1.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
52+
<bindingRedirect oldVersion="1.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
4353
</dependentAssembly>
4454
<dependentAssembly>
4555
<assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />

‎src/vstest.console/app.config‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727
</dependentAssembly>
2828
<dependentAssembly>
2929
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
30-
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
30+
<bindingRedirect oldVersion="0.0.0.0-6.0.3.0" newVersion="6.0.3.0" />
3131
</dependentAssembly>
3232
<dependentAssembly>
3333
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
34-
<bindingRedirect oldVersion="1.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
34+
<bindingRedirect oldVersion="1.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
3535
</dependentAssembly>
3636
<dependentAssembly>
3737
<assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
@@ -40,7 +40,12 @@
4040

4141
<dependentAssembly>
4242
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
43-
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
43+
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
44+
</dependentAssembly>
45+
46+
<dependentAssembly>
47+
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
48+
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
4449
</dependentAssembly>
4550

4651
<dependentAssembly>
@@ -55,7 +60,7 @@
5560

5661
<dependentAssembly>
5762
<assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
58-
<bindingRedirect oldVersion="0.0.0.0-6.0.0.11" newVersion="6.0.0.11" />
63+
<bindingRedirect oldVersion="0.0.0.0-6.0.0.11" newVersion="6.0.0.0" />
5964
</dependentAssembly>
6065
</assemblyBinding>
6166
</runtime>

0 commit comments

Comments
 (0)