diff --git a/Directory.Build.targets b/Directory.Build.targets index 8311c1a9cf..d4ec3b2c27 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -7,6 +7,13 @@ $(DefineConstants);IS_VSTEST_REPO + + $(MSBuildWarningsAsMessages);MSB3277 diff --git a/eng/Version.Details.props b/eng/Version.Details.props index 97bb6dc3b2..7d3f641a07 100644 --- a/eng/Version.Details.props +++ b/eng/Version.Details.props @@ -13,7 +13,7 @@ This file should be imported by eng/Versions.props 0.2.0-preview.26226.111 6.0.2 - 9.0.11 + 10.0.0 1.1.0-beta2-19575-01 1.1.0-beta2-19575-01 diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Microsoft.TestPlatform.CoreUtilities.csproj b/src/Microsoft.TestPlatform.CoreUtilities/Microsoft.TestPlatform.CoreUtilities.csproj index 866225a77c..41188a01ea 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Microsoft.TestPlatform.CoreUtilities.csproj +++ b/src/Microsoft.TestPlatform.CoreUtilities/Microsoft.TestPlatform.CoreUtilities.csproj @@ -18,6 +18,7 @@ + diff --git a/src/Microsoft.TestPlatform.ObjectModel/Microsoft.TestPlatform.ObjectModel.csproj b/src/Microsoft.TestPlatform.ObjectModel/Microsoft.TestPlatform.ObjectModel.csproj index 33872067fb..f27cff3cf6 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Microsoft.TestPlatform.ObjectModel.csproj +++ b/src/Microsoft.TestPlatform.ObjectModel/Microsoft.TestPlatform.ObjectModel.csproj @@ -35,6 +35,7 @@ + diff --git a/src/datacollector/app.config b/src/datacollector/app.config index 9fb228c9dc..2744e280a0 100644 --- a/src/datacollector/app.config +++ b/src/datacollector/app.config @@ -22,11 +22,11 @@ - + - + @@ -34,7 +34,12 @@ - + + + + + + diff --git a/src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.csproj b/src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.csproj index 1497c93107..bfec73c5a5 100644 --- a/src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.csproj +++ b/src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.csproj @@ -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 --> - NU1702 + $(MSBuildWarningsAsMessages);NU1702 diff --git a/src/package/Microsoft.TestPlatform.Portable/Microsoft.TestPlatform.Portable.csproj b/src/package/Microsoft.TestPlatform.Portable/Microsoft.TestPlatform.Portable.csproj index 8583c5cbff..1e86120d0e 100644 --- a/src/package/Microsoft.TestPlatform.Portable/Microsoft.TestPlatform.Portable.csproj +++ b/src/package/Microsoft.TestPlatform.Portable/Microsoft.TestPlatform.Portable.csproj @@ -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 --> - NU1702 + $(MSBuildWarningsAsMessages);NU1702 diff --git a/src/package/Microsoft.TestPlatform/Microsoft.TestPlatform.csproj b/src/package/Microsoft.TestPlatform/Microsoft.TestPlatform.csproj index 9bed4c9ad3..15141365dc 100644 --- a/src/package/Microsoft.TestPlatform/Microsoft.TestPlatform.csproj +++ b/src/package/Microsoft.TestPlatform/Microsoft.TestPlatform.csproj @@ -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 --> - NU1702;NETSDK1023 + $(MSBuildWarningsAsMessages);NU1702;NETSDK1023 diff --git a/src/testhost.x86/app.config b/src/testhost.x86/app.config index 305c4a5a7d..c6e47644e1 100644 --- a/src/testhost.x86/app.config +++ b/src/testhost.x86/app.config @@ -30,11 +30,11 @@ - + - + @@ -42,7 +42,12 @@ - + + + + + + diff --git a/src/vstest.console/app.config b/src/vstest.console/app.config index 36b75a0955..f2bfcfed8c 100644 --- a/src/vstest.console/app.config +++ b/src/vstest.console/app.config @@ -22,11 +22,11 @@ - + - + @@ -35,7 +35,12 @@ - + + + + + + diff --git a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DistributedTestAgentScenarioTests.cs b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DistributedTestAgentScenarioTests.cs new file mode 100644 index 0000000000..972a6d6f2c --- /dev/null +++ b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DistributedTestAgentScenarioTests.cs @@ -0,0 +1,101 @@ +// 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; +using System.IO; +using System.Linq; +using System.Reflection.Metadata; +using System.Reflection.PortableExecutable; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Microsoft.TestPlatform.AcceptanceTests; + +/// +/// Tests that the DTA (Distributed Test Agent) scenario works: a .NET Framework host +/// loads Microsoft.VisualStudio.TestPlatform.Common.dll without binding redirects. The shipped +/// System.Collections.Immutable DLL must match the assembly version referenced by +/// the compiled product assemblies. +/// +[TestClass] +public class DistributedTestAgentScenarioTests : AcceptanceTestBase +{ + /// + /// Validates that the Microsoft.TestPlatform nupkg layout (used by DTA/VSTest task) + /// contains a System.Collections.Immutable whose assembly version matches what + /// Common.dll was compiled against. + /// + [TestMethod] + public void NupkgLayout_CommonDll_CanLoadSciWithoutBindingRedirects() + { + var testPlatformDir = Path.Combine( + IntegrationTestEnvironment.PublishDirectory, + $"Microsoft.TestPlatform.{IntegrationTestEnvironment.LatestLocallyBuiltNugetVersion}.nupkg", + "tools", "net462", "Common7", "IDE", "Extensions", "TestPlatform"); + + ValidateDtaScenario(testPlatformDir, "nupkg"); + } + + /// + /// Validates that the V2.CLI VSIX layout also has matching SCI assembly versions. + /// + [TestMethod] + public void VsixLayout_CommonDll_CanLoadSciWithoutBindingRedirects() + { + var vsixDir = Path.GetDirectoryName(IntegrationTestEnvironment.LocalVsixInsertion); + if (vsixDir is null || !Directory.Exists(vsixDir)) + { + Assert.Inconclusive("VSIX directory not found. Build with -pack to produce it."); + } + + var vsixExtractDir = Path.Combine(IntegrationTestEnvironment.ArtifactsTempDirectory, "vsix-extracted"); + if (!Directory.Exists(vsixExtractDir)) + { + System.IO.Compression.ZipFile.ExtractToDirectory(IntegrationTestEnvironment.LocalVsixInsertion, vsixExtractDir); + } + + ValidateDtaScenario(vsixExtractDir, "VSIX"); + } + + private static void ValidateDtaScenario(string testPlatformDir, string layoutName) + { + Assert.IsTrue(Directory.Exists(testPlatformDir), $"{layoutName} directory not found: {testPlatformDir}"); + + var commonDll = Path.Combine(testPlatformDir, "Microsoft.VisualStudio.TestPlatform.Common.dll"); + var sciDll = Path.Combine(testPlatformDir, "System.Collections.Immutable.dll"); + + Assert.IsTrue(File.Exists(commonDll), $"Common.dll not found in {layoutName} layout: {commonDll}"); + Assert.IsTrue(File.Exists(sciDll), $"System.Collections.Immutable.dll not found in {layoutName} layout: {sciDll}"); + + var sciVersion = System.Reflection.AssemblyName.GetAssemblyName(sciDll).Version; + var sciRefVersion = GetReferencedAssemblyVersion(commonDll, "System.Collections.Immutable"); + + Assert.IsNotNull(sciRefVersion, $"Common.dll in {layoutName} layout does not reference System.Collections.Immutable"); + + // For DTA scenario (no binding redirects), these MUST match exactly. + Assert.AreEqual( + sciRefVersion, + sciVersion, + $"{layoutName} layout: Common.dll references SCI {sciRefVersion} but shipped DLL is {sciVersion}. " + + $"DTA hosts without binding redirects will fail with FileLoadException."); + } + + private static Version? GetReferencedAssemblyVersion(string assemblyPath, string referenceName) + { + using var stream = File.OpenRead(assemblyPath); + using var peReader = new PEReader(stream); + var mdReader = peReader.GetMetadataReader(); + foreach (var handle in mdReader.AssemblyReferences) + { + var asmRef = mdReader.GetAssemblyReference(handle); + if (mdReader.GetString(asmRef.Name) == referenceName) + { + return asmRef.Version; + } + } + + return null; + } +} +