Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@

<PropertyGroup>
<DefineConstants Condition="'$(IsFilterSourcePackage)' != 'true'">$(DefineConstants);IS_VSTEST_REPO</DefineConstants>
<!--
MSB3277: netstandard2.0 product assemblies reference SCI 9.0.0.0 (from the explicit
PackageReference needed for the DTA scenario — see issue #15718), but .NETCoreApp
targets have inbox SCI 8.0.0.0. This is harmless: .NET Core assembly loading is
version-tolerant and will load the available version regardless of the reference.
-->
<MSBuildWarningsAsMessages Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">$(MSBuildWarningsAsMessages);MSB3277</MSBuildWarningsAsMessages>
</PropertyGroup>

<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
Expand Down
2 changes: 1 addition & 1 deletion eng/Version.Details.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This file should be imported by eng/Versions.props
<MicrosoftDiagnosticsNETCoreClientPackageVersion>0.2.0-preview.26251.112</MicrosoftDiagnosticsNETCoreClientPackageVersion>
<!-- dotnet-runtime dependencies -->
<MicrosoftExtensionsDependencyModelPackageVersion>6.0.2</MicrosoftExtensionsDependencyModelPackageVersion>
<SystemCollectionsImmutablePackageVersion>9.0.11</SystemCollectionsImmutablePackageVersion>
<SystemCollectionsImmutablePackageVersion>10.0.0</SystemCollectionsImmutablePackageVersion>
<!-- dotnet-symreader-converter dependencies -->
<MicrosoftDiaSymReaderConverterPackageVersion>1.1.0-beta2-19575-01</MicrosoftDiaSymReaderConverterPackageVersion>
<MicrosoftDiaSymReaderPdb2PdbPackageVersion>1.1.0-beta2-19575-01</MicrosoftDiaSymReaderPdb2PdbPackageVersion>
Expand Down
24 changes: 12 additions & 12 deletions eng/expected-dll-frameworks.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@
"tools/net462/Common7/IDE/Extensions/TestPlatform/pl/Microsoft.CodeCoverage.IO.dll": "none",
"tools/net462/Common7/IDE/Extensions/TestPlatform/pt-BR/Microsoft.CodeCoverage.IO.dll": "none",
"tools/net462/Common7/IDE/Extensions/TestPlatform/ru/Microsoft.CodeCoverage.IO.dll": "none",
"tools/net462/Common7/IDE/Extensions/TestPlatform/System.Buffers.dll": "none",
"tools/net462/Common7/IDE/Extensions/TestPlatform/System.Buffers.dll": "netframework",
"tools/net462/Common7/IDE/Extensions/TestPlatform/System.Collections.Immutable.dll": "netstandard",
"tools/net462/Common7/IDE/Extensions/TestPlatform/System.Memory.dll": "none",
"tools/net462/Common7/IDE/Extensions/TestPlatform/System.Numerics.Vectors.dll": "none",
"tools/net462/Common7/IDE/Extensions/TestPlatform/System.Memory.dll": "netframework",
"tools/net462/Common7/IDE/Extensions/TestPlatform/System.Numerics.Vectors.dll": "netframework",
"tools/net462/Common7/IDE/Extensions/TestPlatform/System.Reflection.Metadata.dll": "netstandard",
"tools/net462/Common7/IDE/Extensions/TestPlatform/System.Runtime.CompilerServices.Unsafe.dll": "none",
"tools/net462/Common7/IDE/Extensions/TestPlatform/TestHostNet/Microsoft.TestPlatform.CommunicationUtilities.dll": "netframework",
Expand Down Expand Up @@ -190,7 +190,7 @@
"contentFiles/any/net10.0/TestHostNetFramework/Microsoft.Win32.Primitives.dll": "none",
"contentFiles/any/net10.0/TestHostNetFramework/netstandard.dll": "none",
"contentFiles/any/net10.0/TestHostNetFramework/System.AppContext.dll": "none",
"contentFiles/any/net10.0/TestHostNetFramework/System.Buffers.dll": "none",
"contentFiles/any/net10.0/TestHostNetFramework/System.Buffers.dll": "netframework",
"contentFiles/any/net10.0/TestHostNetFramework/System.Collections.Concurrent.dll": "none",
"contentFiles/any/net10.0/TestHostNetFramework/System.Collections.dll": "none",
"contentFiles/any/net10.0/TestHostNetFramework/System.Collections.Immutable.dll": "netstandard",
Expand Down Expand Up @@ -231,7 +231,7 @@
"contentFiles/any/net10.0/TestHostNetFramework/System.Linq.Expressions.dll": "none",
"contentFiles/any/net10.0/TestHostNetFramework/System.Linq.Parallel.dll": "none",
"contentFiles/any/net10.0/TestHostNetFramework/System.Linq.Queryable.dll": "none",
"contentFiles/any/net10.0/TestHostNetFramework/System.Memory.dll": "none",
"contentFiles/any/net10.0/TestHostNetFramework/System.Memory.dll": "netframework",
"contentFiles/any/net10.0/TestHostNetFramework/System.Net.Http.dll": "none",
"contentFiles/any/net10.0/TestHostNetFramework/System.Net.NameResolution.dll": "none",
"contentFiles/any/net10.0/TestHostNetFramework/System.Net.NetworkInformation.dll": "none",
Expand All @@ -243,7 +243,7 @@
"contentFiles/any/net10.0/TestHostNetFramework/System.Net.WebHeaderCollection.dll": "none",
"contentFiles/any/net10.0/TestHostNetFramework/System.Net.WebSockets.Client.dll": "none",
"contentFiles/any/net10.0/TestHostNetFramework/System.Net.WebSockets.dll": "none",
"contentFiles/any/net10.0/TestHostNetFramework/System.Numerics.Vectors.dll": "none",
"contentFiles/any/net10.0/TestHostNetFramework/System.Numerics.Vectors.dll": "netframework",
"contentFiles/any/net10.0/TestHostNetFramework/System.ObjectModel.dll": "none",
"contentFiles/any/net10.0/TestHostNetFramework/System.Reflection.dll": "none",
"contentFiles/any/net10.0/TestHostNetFramework/System.Reflection.Extensions.dll": "none",
Expand Down Expand Up @@ -342,10 +342,10 @@
"tools/net462/pl/Microsoft.CodeCoverage.IO.dll": "none",
"tools/net462/pt-BR/Microsoft.CodeCoverage.IO.dll": "none",
"tools/net462/ru/Microsoft.CodeCoverage.IO.dll": "none",
"tools/net462/System.Buffers.dll": "none",
"tools/net462/System.Buffers.dll": "netframework",
"tools/net462/System.Collections.Immutable.dll": "netstandard",
"tools/net462/System.Memory.dll": "none",
"tools/net462/System.Numerics.Vectors.dll": "none",
"tools/net462/System.Memory.dll": "netframework",
"tools/net462/System.Numerics.Vectors.dll": "netframework",
"tools/net462/System.Reflection.Metadata.dll": "netstandard",
"tools/net462/System.Runtime.CompilerServices.Unsafe.dll": "none",
"tools/net462/System.Runtime.InteropServices.RuntimeInformation.dll": "none",
Expand Down Expand Up @@ -451,11 +451,11 @@
"Microsoft.VisualStudio.TestPlatform.Client.dll": "netframework",
"Microsoft.VisualStudio.TestPlatform.Common.dll": "netframework",
"Microsoft.VisualStudio.TestPlatform.ObjectModel.dll": "netframework",
"System.Buffers.dll": "none",
"System.Buffers.dll": "netframework",
"System.Collections.Immutable.dll": "netstandard",
"System.Diagnostics.DiagnosticSource.dll": "netstandard",
"System.Memory.dll": "none",
"System.Numerics.Vectors.dll": "none",
"System.Memory.dll": "netframework",
"System.Numerics.Vectors.dll": "netframework",
"System.Reflection.Metadata.dll": "netstandard",
"System.Runtime.CompilerServices.Unsafe.dll": "none",
"System.Text.Json.dll": "netframework",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<ItemGroup>
<!-- net48 includes tuple, we need to reference it in previous versions but only on .net framework. -->
<PackageReference Include="System.ValueTuple" Version="4.5.0" Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net48')) != 'true' and '$(TargetFrameworkIdentifier)' == '.NETFramework'" />
<PackageReference Include="System.Collections.Immutable" Version="$(SystemCollectionsImmutablePackageVersion)" Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'" />
<PackageReference Include="System.Reflection.Metadata" Version="$(SystemReflectionMetadataVersion)" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'" />
</ItemGroup>

Expand Down
11 changes: 8 additions & 3 deletions src/datacollector/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,24 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
<bindingRedirect oldVersion="1.0.0.0-6.0.3.0" newVersion="6.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
<bindingRedirect oldVersion="1.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
</dependentAssembly>

<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
Sometimes NU1702 is not suppressed correctly, so force reducing severity of the warning.
See https://github.com/NuGet/Home/issues/9147
-->
<MSBuildWarningsAsMessages>NU1702</MSBuildWarningsAsMessages>
<MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);NU1702</MSBuildWarningsAsMessages>
</PropertyGroup>

<!-- runner and runner dependencies -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Sometimes NU1702 is not suppressed correctly, so force reducing severity of the warning.
See https://github.com/NuGet/Home/issues/9147
-->
<MSBuildWarningsAsMessages>NU1702</MSBuildWarningsAsMessages>
<MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);NU1702</MSBuildWarningsAsMessages>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Sometimes NU1702 is not suppressed correctly, so force reducing severity of the warning.
See https://github.com/NuGet/Home/issues/9147
-->
<MSBuildWarningsAsMessages>NU1702;NETSDK1023</MSBuildWarningsAsMessages>
<MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);NU1702;NETSDK1023</MSBuildWarningsAsMessages>
</PropertyGroup>

<PropertyGroup>
Expand Down
11 changes: 8 additions & 3 deletions src/testhost.x86/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,24 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
<bindingRedirect oldVersion="1.0.0.0-6.0.3.0" newVersion="6.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
<bindingRedirect oldVersion="1.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
</dependentAssembly>

<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Expand Down
11 changes: 8 additions & 3 deletions src/vstest.console/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
<bindingRedirect oldVersion="1.0.0.0-6.0.3.0" newVersion="6.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
<bindingRedirect oldVersion="1.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
Expand All @@ -35,7 +35,12 @@

<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
</dependentAssembly>

<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
</dependentAssembly>

<dependentAssembly>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.IO;

using Microsoft.TestPlatform.TestUtilities;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Microsoft.TestPlatform.AcceptanceTests;

/// <summary>
/// Reproduces the binding-redirect scenario experienced by Azure DevOps' Distributed
/// Test Agent (DTAExecutionHost) and any Visual Studio host that picks up
/// <c>Microsoft.VisualStudio.TestPlatform.Common.dll</c> without the in-box
/// <c>vstest.console.exe.config</c> binding redirects.
///
/// The test loads <c>Common.dll</c> inside a net472 host that has no binding
/// redirects in its app.config and calls
/// <see cref="Microsoft.VisualStudio.TestPlatform.Common.Filtering.FilterExpressionWrapper"/>,
/// which triggers <c>FastFilter.Builder</c> and forces
/// <c>System.Collections.Immutable</c> / <c>System.Reflection.Metadata</c> to load.
///
/// It runs the scenario twice:
/// 1. Against the <c>Microsoft.TestPlatform</c> nupkg's
/// <c>tools/net462/Common7/IDE/Extensions/TestPlatform/</c> layout (as DTA consumes it).
/// 2. Against the flat layout of the <c>Microsoft.VisualStudio.TestTools.TestPlatform.V2.CLI</c>
/// VSIX (as Visual Studio consumes it).
///
/// Regression guard: if <c>Common.dll</c>'s compiled metadata references for SCI/SRM drift
/// away from the versions we ship next to it, the test fails with the same
/// <c>FileLoadException</c> customers see. Both layouts must stay self-consistent.
/// </summary>
[TestClass]
public class DistributedTestAgentScenarioTests : AcceptanceTestBase
{
[TestMethod]
[TestCategory("Windows-Review")]
public void LoadingCommonDllFromMicrosoftTestPlatformPackageWithoutBindingRedirectsDoesNotThrow()
{
// Nupkg layout: DTA-style consumption of the Microsoft.TestPlatform nupkg.
RunDtaLikeHost(toolsDirOverride: null);
}

[TestMethod]
[TestCategory("Windows-Review")]
public void LoadingCommonDllFromCliV2VsixLayoutWithoutBindingRedirectsDoesNotThrow()
{
// VSIX layout: flat folder with Common.dll + SCI + SRM at the root, as shipped
// in Microsoft.VisualStudio.TestTools.TestPlatform.V2.CLI.vsix and consumed by
// Visual Studio. The VSIX is unzipped into PublishDirectory by Build.cs.
var extractedVsixDir = Path.Combine(
IntegrationTestEnvironment.PublishDirectory,
Path.GetFileName(IntegrationTestEnvironment.LocalVsixInsertion));

Assert.IsTrue(
Directory.Exists(extractedVsixDir),
$"Extracted VSIX directory not found at '{extractedVsixDir}'. " +
"Build.cs is expected to unzip the V2.CLI VSIX before acceptance tests run.");

Assert.IsTrue(
File.Exists(Path.Combine(extractedVsixDir, "Microsoft.VisualStudio.TestPlatform.Common.dll")),
$"Expected Common.dll at the root of the extracted VSIX ('{extractedVsixDir}').");

RunDtaLikeHost(toolsDirOverride: extractedVsixDir);
}

private void RunDtaLikeHost(string? toolsDirOverride)
{
var projectPath = GetIsolatedTestAsset("DtaLikeHost.csproj", "net472");
var workingDir = Path.GetDirectoryName(projectPath)!;

var dotnetPath = GetPatchedDotnetPath();

var buildArgs =
$@"build ""{projectPath}"" -c {IntegrationTestEnvironment.BuildConfiguration} " +
$@"/p:PackageVersion={IntegrationTestEnvironment.LatestLocallyBuiltNugetVersion} " +
@"/nodeReuse:false";

if (toolsDirOverride is not null)
{
buildArgs += $@" /p:TestPlatformToolsDirOverride=""{toolsDirOverride}""";
}

ExecuteApplication(dotnetPath, buildArgs, out var buildOut, out var buildErr, out var buildExit, workingDirectory: workingDir);

Assert.AreEqual(
0,
buildExit,
$"dotnet build of DtaLikeHost failed (exit {buildExit}).\nSTDOUT:\n{buildOut}\nSTDERR:\n{buildErr}");

var exePath = Path.Combine(
workingDir,
"artifacts", "bin", "TestAssets", "DtaLikeHost",
IntegrationTestEnvironment.BuildConfiguration,
"net472",
"DtaLikeHost.exe");

Assert.IsTrue(File.Exists(exePath), $"Expected DtaLikeHost.exe at '{exePath}'.");

// With the fix in place, Common.dll's compiled metadata references for
// System.Collections.Immutable and System.Reflection.Metadata match the DLLs
// shipped next to it, so the host exe completes normally even without any
// binding redirects in its app.config.
ExecuteApplication(exePath, args: null, out var runOut, out var runErr, out var runExit);

Assert.AreEqual(
0,
runExit,
"DtaLikeHost.exe exited non-zero, which means Common.dll's compiled metadata " +
"references for System.Collections.Immutable / System.Reflection.Metadata do " +
"not match the versions shipped next to it. DTA-style hosts (no binding " +
"redirects) will FileLoadException on FastFilter.Builder.\n" +
$"Tools dir: {toolsDirOverride ?? "<nupkg default>"}\n" +
$"STDOUT:\n{runOut}\nSTDERR:\n{runErr}");

Assert.Contains("OK - no binding exception.", runOut);
}

private static string GetPatchedDotnetPath()
{
var executable = OSUtils.IsWindows ? "dotnet.exe" : "dotnet";
return Path.GetFullPath(Path.Combine(IntegrationTestEnvironment.RepoRootDirectory, "artifacts", "tmp", ".dotnet", executable));
}
}
Loading