Skip to content

Commit 9c9c063

Browse files
nohwndCopilot
andauthored
Fix SCI binding failure in DTA hosts (main) (#15724)
* 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 (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 #15718 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Remove unused DtaLikeHost test asset * Remove old ExcludeAssets approach from Directory.Build.targets 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> * Fix stale nupkg file count for V2.CLI (389, not 484) 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 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> * Fix System.Memory and Unsafe binding redirect versions for Release builds 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> * Update V2.CLI nupkg file count to 389 (clean build) 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> * Add System.Buffers binding redirect to all app.configs 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> * Use DtaLikeHost exe for SCI binding test 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> * Update expected-dll-frameworks.json for SCI 10.0.0 deps 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> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent a1c73b5 commit 9c9c063

14 files changed

Lines changed: 300 additions & 25 deletions

File tree

Directory.Build.targets

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77

88
<PropertyGroup>
99
<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>
1017
</PropertyGroup>
1118

1219
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />

eng/Version.Details.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This file should be imported by eng/Versions.props
1313
<MicrosoftDiagnosticsNETCoreClientPackageVersion>0.2.0-preview.26251.112</MicrosoftDiagnosticsNETCoreClientPackageVersion>
1414
<!-- dotnet-runtime dependencies -->
1515
<MicrosoftExtensionsDependencyModelPackageVersion>6.0.2</MicrosoftExtensionsDependencyModelPackageVersion>
16-
<SystemCollectionsImmutablePackageVersion>9.0.11</SystemCollectionsImmutablePackageVersion>
16+
<SystemCollectionsImmutablePackageVersion>10.0.0</SystemCollectionsImmutablePackageVersion>
1717
<!-- dotnet-symreader-converter dependencies -->
1818
<MicrosoftDiaSymReaderConverterPackageVersion>1.1.0-beta2-19575-01</MicrosoftDiaSymReaderConverterPackageVersion>
1919
<MicrosoftDiaSymReaderPdb2PdbPackageVersion>1.1.0-beta2-19575-01</MicrosoftDiaSymReaderPdb2PdbPackageVersion>

eng/expected-dll-frameworks.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@
125125
"tools/net462/Common7/IDE/Extensions/TestPlatform/pl/Microsoft.CodeCoverage.IO.dll": "none",
126126
"tools/net462/Common7/IDE/Extensions/TestPlatform/pt-BR/Microsoft.CodeCoverage.IO.dll": "none",
127127
"tools/net462/Common7/IDE/Extensions/TestPlatform/ru/Microsoft.CodeCoverage.IO.dll": "none",
128-
"tools/net462/Common7/IDE/Extensions/TestPlatform/System.Buffers.dll": "none",
128+
"tools/net462/Common7/IDE/Extensions/TestPlatform/System.Buffers.dll": "netframework",
129129
"tools/net462/Common7/IDE/Extensions/TestPlatform/System.Collections.Immutable.dll": "netstandard",
130-
"tools/net462/Common7/IDE/Extensions/TestPlatform/System.Memory.dll": "none",
131-
"tools/net462/Common7/IDE/Extensions/TestPlatform/System.Numerics.Vectors.dll": "none",
130+
"tools/net462/Common7/IDE/Extensions/TestPlatform/System.Memory.dll": "netframework",
131+
"tools/net462/Common7/IDE/Extensions/TestPlatform/System.Numerics.Vectors.dll": "netframework",
132132
"tools/net462/Common7/IDE/Extensions/TestPlatform/System.Reflection.Metadata.dll": "netstandard",
133133
"tools/net462/Common7/IDE/Extensions/TestPlatform/System.Runtime.CompilerServices.Unsafe.dll": "none",
134134
"tools/net462/Common7/IDE/Extensions/TestPlatform/TestHostNet/Microsoft.TestPlatform.CommunicationUtilities.dll": "netframework",
@@ -190,7 +190,7 @@
190190
"contentFiles/any/net10.0/TestHostNetFramework/Microsoft.Win32.Primitives.dll": "none",
191191
"contentFiles/any/net10.0/TestHostNetFramework/netstandard.dll": "none",
192192
"contentFiles/any/net10.0/TestHostNetFramework/System.AppContext.dll": "none",
193-
"contentFiles/any/net10.0/TestHostNetFramework/System.Buffers.dll": "none",
193+
"contentFiles/any/net10.0/TestHostNetFramework/System.Buffers.dll": "netframework",
194194
"contentFiles/any/net10.0/TestHostNetFramework/System.Collections.Concurrent.dll": "none",
195195
"contentFiles/any/net10.0/TestHostNetFramework/System.Collections.dll": "none",
196196
"contentFiles/any/net10.0/TestHostNetFramework/System.Collections.Immutable.dll": "netstandard",
@@ -231,7 +231,7 @@
231231
"contentFiles/any/net10.0/TestHostNetFramework/System.Linq.Expressions.dll": "none",
232232
"contentFiles/any/net10.0/TestHostNetFramework/System.Linq.Parallel.dll": "none",
233233
"contentFiles/any/net10.0/TestHostNetFramework/System.Linq.Queryable.dll": "none",
234-
"contentFiles/any/net10.0/TestHostNetFramework/System.Memory.dll": "none",
234+
"contentFiles/any/net10.0/TestHostNetFramework/System.Memory.dll": "netframework",
235235
"contentFiles/any/net10.0/TestHostNetFramework/System.Net.Http.dll": "none",
236236
"contentFiles/any/net10.0/TestHostNetFramework/System.Net.NameResolution.dll": "none",
237237
"contentFiles/any/net10.0/TestHostNetFramework/System.Net.NetworkInformation.dll": "none",
@@ -243,7 +243,7 @@
243243
"contentFiles/any/net10.0/TestHostNetFramework/System.Net.WebHeaderCollection.dll": "none",
244244
"contentFiles/any/net10.0/TestHostNetFramework/System.Net.WebSockets.Client.dll": "none",
245245
"contentFiles/any/net10.0/TestHostNetFramework/System.Net.WebSockets.dll": "none",
246-
"contentFiles/any/net10.0/TestHostNetFramework/System.Numerics.Vectors.dll": "none",
246+
"contentFiles/any/net10.0/TestHostNetFramework/System.Numerics.Vectors.dll": "netframework",
247247
"contentFiles/any/net10.0/TestHostNetFramework/System.ObjectModel.dll": "none",
248248
"contentFiles/any/net10.0/TestHostNetFramework/System.Reflection.dll": "none",
249249
"contentFiles/any/net10.0/TestHostNetFramework/System.Reflection.Extensions.dll": "none",
@@ -342,10 +342,10 @@
342342
"tools/net462/pl/Microsoft.CodeCoverage.IO.dll": "none",
343343
"tools/net462/pt-BR/Microsoft.CodeCoverage.IO.dll": "none",
344344
"tools/net462/ru/Microsoft.CodeCoverage.IO.dll": "none",
345-
"tools/net462/System.Buffers.dll": "none",
345+
"tools/net462/System.Buffers.dll": "netframework",
346346
"tools/net462/System.Collections.Immutable.dll": "netstandard",
347-
"tools/net462/System.Memory.dll": "none",
348-
"tools/net462/System.Numerics.Vectors.dll": "none",
347+
"tools/net462/System.Memory.dll": "netframework",
348+
"tools/net462/System.Numerics.Vectors.dll": "netframework",
349349
"tools/net462/System.Reflection.Metadata.dll": "netstandard",
350350
"tools/net462/System.Runtime.CompilerServices.Unsafe.dll": "none",
351351
"tools/net462/System.Runtime.InteropServices.RuntimeInformation.dll": "none",
@@ -451,11 +451,11 @@
451451
"Microsoft.VisualStudio.TestPlatform.Client.dll": "netframework",
452452
"Microsoft.VisualStudio.TestPlatform.Common.dll": "netframework",
453453
"Microsoft.VisualStudio.TestPlatform.ObjectModel.dll": "netframework",
454-
"System.Buffers.dll": "none",
454+
"System.Buffers.dll": "netframework",
455455
"System.Collections.Immutable.dll": "netstandard",
456456
"System.Diagnostics.DiagnosticSource.dll": "netstandard",
457-
"System.Memory.dll": "none",
458-
"System.Numerics.Vectors.dll": "none",
457+
"System.Memory.dll": "netframework",
458+
"System.Numerics.Vectors.dll": "netframework",
459459
"System.Reflection.Metadata.dll": "netstandard",
460460
"System.Runtime.CompilerServices.Unsafe.dll": "none",
461461
"System.Text.Json.dll": "netframework",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
<ItemGroup>
2020
<PackageReference Include="Microsoft.Win32.Registry" Version="$(MicrosoftWin32RegistryVersion)" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
21+
<PackageReference Include="System.Collections.Immutable" Version="$(SystemCollectionsImmutablePackageVersion)" Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'" />
2122
<PackageReference Include="System.Reflection.Metadata" Version="$(SystemReflectionMetadataVersion)" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'" />
2223
</ItemGroup>
2324

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<ItemGroup>
3636
<!-- net48 includes tuple, we need to reference it in previous versions but only on .net framework. -->
3737
<PackageReference Include="System.ValueTuple" Version="4.5.0" Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net48')) != 'true' and '$(TargetFrameworkIdentifier)' == '.NETFramework'" />
38+
<PackageReference Include="System.Collections.Immutable" Version="$(SystemCollectionsImmutablePackageVersion)" Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'" />
3839
<PackageReference Include="System.Reflection.Metadata" Version="$(SystemReflectionMetadataVersion)" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'" />
3940
</ItemGroup>
4041

src/datacollector/app.config

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,24 @@
2222
</dependentAssembly>
2323
<dependentAssembly>
2424
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
25-
<bindingRedirect oldVersion="1.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
25+
<bindingRedirect oldVersion="1.0.0.0-6.0.3.0" newVersion="6.0.3.0" />
2626
</dependentAssembly>
2727
<dependentAssembly>
2828
<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" />
29+
<bindingRedirect oldVersion="1.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
3030
</dependentAssembly>
3131
<dependentAssembly>
3232
<assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
3333
<bindingRedirect oldVersion="1.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
3434
</dependentAssembly>
3535
<dependentAssembly>
3636
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
37-
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
37+
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
38+
</dependentAssembly>
39+
40+
<dependentAssembly>
41+
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
42+
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
3843
</dependentAssembly>
3944
</assemblyBinding>
4045
</runtime>

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: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,24 @@
3030
</dependentAssembly>
3131
<dependentAssembly>
3232
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
33-
<bindingRedirect oldVersion="1.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
33+
<bindingRedirect oldVersion="1.0.0.0-6.0.3.0" newVersion="6.0.3.0" />
3434
</dependentAssembly>
3535
<dependentAssembly>
3636
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
37-
<bindingRedirect oldVersion="1.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
37+
<bindingRedirect oldVersion="1.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
3838
</dependentAssembly>
3939
<dependentAssembly>
4040
<assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
4141
<bindingRedirect oldVersion="1.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
4242
</dependentAssembly>
4343
<dependentAssembly>
4444
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
45-
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
45+
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
46+
</dependentAssembly>
47+
48+
<dependentAssembly>
49+
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
50+
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
4651
</dependentAssembly>
4752
</assemblyBinding>
4853
</runtime>

0 commit comments

Comments
 (0)