From bb93dadd906e8eb98e58361b746f671f5b2e2e4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Mon, 8 Jul 2024 17:20:07 +0200 Subject: [PATCH 1/2] Runtime config fallback --- eng/verify-nupkgs.ps1 | 4 ++-- playground/TestPlatform.Playground/Environment.cs | 4 ++-- playground/TestPlatform.Playground/Program.cs | 6 +++--- .../Hosting/DotnetTestHostManager.cs | 5 +++++ .../Microsoft.TestPlatform.CLI.nuspec | 1 + .../Microsoft.TestPlatform.CLI.sourcebuild.nuspec | 2 ++ ...Microsoft.TestPlatform.CLI.sourcebuild.product.nuspec | 1 + .../Microsoft.TestPlatform/Microsoft.TestPlatform.nuspec | 1 + temp/testhost/testhost-9.0.runtimeconfig.json | 9 +++++++++ 9 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 temp/testhost/testhost-9.0.runtimeconfig.json diff --git a/eng/verify-nupkgs.ps1 b/eng/verify-nupkgs.ps1 index c87d4ceaab..3bb7d9c3ee 100644 --- a/eng/verify-nupkgs.ps1 +++ b/eng/verify-nupkgs.ps1 @@ -19,9 +19,9 @@ function Verify-Nuget-Packages { $expectedNumOfFiles = @{ "Microsoft.CodeCoverage" = 59; "Microsoft.NET.Test.Sdk" = 15; - "Microsoft.TestPlatform" = 607; + "Microsoft.TestPlatform" = 608; "Microsoft.TestPlatform.Build" = 20; - "Microsoft.TestPlatform.CLI" = 470; + "Microsoft.TestPlatform.CLI" = 471; "Microsoft.TestPlatform.Extensions.TrxLogger" = 34; "Microsoft.TestPlatform.ObjectModel" = 92; "Microsoft.TestPlatform.AdapterUtilities" = 75; diff --git a/playground/TestPlatform.Playground/Environment.cs b/playground/TestPlatform.Playground/Environment.cs index d7ba86c869..6884c10a3a 100644 --- a/playground/TestPlatform.Playground/Environment.cs +++ b/playground/TestPlatform.Playground/Environment.cs @@ -11,8 +11,8 @@ internal class EnvironmentVariables { ["VSTEST_CONNECTION_TIMEOUT"] = "999", ["VSTEST_DEBUG_NOBP"] = "1", - ["VSTEST_RUNNER_DEBUG_ATTACHVS"] = "0", - ["VSTEST_HOST_DEBUG_ATTACHVS"] = "0", + ["VSTEST_RUNNER_DEBUG_ATTACHVS"] = "1", + ["VSTEST_HOST_DEBUG_ATTACHVS"] = "1", ["VSTEST_DATACOLLECTOR_DEBUG_ATTACHVS"] = "0", }; diff --git a/playground/TestPlatform.Playground/Program.cs b/playground/TestPlatform.Playground/Program.cs index 142b324cb3..066ec4e026 100644 --- a/playground/TestPlatform.Playground/Program.cs +++ b/playground/TestPlatform.Playground/Program.cs @@ -35,7 +35,6 @@ static void Main() var thisAssemblyPath = Assembly.GetEntryAssembly()!.Location; var here = Path.GetDirectoryName(thisAssemblyPath)!; - var playground = Path.GetFullPath(Path.Combine(here, "..", "..", "..", "..")); var console = Path.Combine(here, "vstest.console", "netfx", "vstest.console.exe"); @@ -88,8 +87,9 @@ static void Main() """; var sources = new[] { - Path.Combine(playground, "bin", "MSTest1", "Debug", "net472", "MSTest1.dll"), - Path.Combine(playground, "bin", "MSTest2", "Debug", "net472", "MSTest2.dll"), + "S:\\t\\nunit9\\bin\\Debug\\net9.0\\nunit9.dll" + //Path.Combine(playground, "bin", "MSTest1", "Debug", "net472", "MSTest1.dll"), + //Path.Combine(playground, "bin", "MSTest2", "Debug", "net472", "MSTest2.dll"), // The built in .NET projects don't now work right now in Playground, there is some conflict with Arcade. // But if you create one outside of Playground it will work. //Path.Combine(playground, "bin", "MSTest1", "Debug", "net7.0", "MSTest1.dll"), diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs b/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs index b8e621f077..89c019556b 100644 --- a/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs +++ b/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs @@ -415,6 +415,11 @@ public virtual TestProcessStartInfo GetTestHostProcessStartInfo( // 2) making sure we still make the project executable (and so we actually do get runtimeconfig unless the user tries hard to not make the test and EXE). var suffix = _targetFramework.Version == "1.0.0.0" ? "latest" : $"{new Version(_targetFramework.Version).Major}.{new Version(_targetFramework.Version).Minor}"; var testhostRuntimeConfig = Path.Combine(Path.GetDirectoryName(testHostNextToRunner)!, $"testhost-{suffix}.runtimeconfig.json"); + if (!File.Exists(testhostRuntimeConfig)) + { + testhostRuntimeConfig = Path.Combine(Path.GetDirectoryName(testHostNextToRunner)!, $"testhost-latest.runtimeconfig.json"); + } + argsToAdd = " --runtimeconfig " + testhostRuntimeConfig.AddDoubleQuote(); args += argsToAdd; EqtTrace.Verbose("DotnetTestHostmanager: Adding {0} in args", argsToAdd); diff --git a/src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.nuspec b/src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.nuspec index 7af61c0a59..e5d37dcb48 100644 --- a/src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.nuspec +++ b/src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.nuspec @@ -45,6 +45,7 @@ + diff --git a/src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.sourcebuild.nuspec b/src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.sourcebuild.nuspec index 3f1469375e..163cd961fd 100644 --- a/src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.sourcebuild.nuspec +++ b/src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.sourcebuild.nuspec @@ -71,6 +71,8 @@ + + diff --git a/src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.sourcebuild.product.nuspec b/src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.sourcebuild.product.nuspec index 5541bce3eb..e53eaba922 100644 --- a/src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.sourcebuild.product.nuspec +++ b/src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.sourcebuild.product.nuspec @@ -44,6 +44,7 @@ + diff --git a/src/package/Microsoft.TestPlatform/Microsoft.TestPlatform.nuspec b/src/package/Microsoft.TestPlatform/Microsoft.TestPlatform.nuspec index 0903b475db..812cab1cfe 100644 --- a/src/package/Microsoft.TestPlatform/Microsoft.TestPlatform.nuspec +++ b/src/package/Microsoft.TestPlatform/Microsoft.TestPlatform.nuspec @@ -541,6 +541,7 @@ + diff --git a/temp/testhost/testhost-9.0.runtimeconfig.json b/temp/testhost/testhost-9.0.runtimeconfig.json new file mode 100644 index 0000000000..146e13202e --- /dev/null +++ b/temp/testhost/testhost-9.0.runtimeconfig.json @@ -0,0 +1,9 @@ +{ + "runtimeOptions": { + "tfm": "net9.0", + "framework": { + "name": "Microsoft.NETCore.App", + "version": "9.0.0-preview.0" + } + } +} From c729a0832a6c14ffad86e3e7f2ed56da82185789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Mon, 8 Jul 2024 17:32:57 +0200 Subject: [PATCH 2/2] Revert playground --- playground/TestPlatform.Playground/Environment.cs | 4 ++-- playground/TestPlatform.Playground/Program.cs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/playground/TestPlatform.Playground/Environment.cs b/playground/TestPlatform.Playground/Environment.cs index 6884c10a3a..d7ba86c869 100644 --- a/playground/TestPlatform.Playground/Environment.cs +++ b/playground/TestPlatform.Playground/Environment.cs @@ -11,8 +11,8 @@ internal class EnvironmentVariables { ["VSTEST_CONNECTION_TIMEOUT"] = "999", ["VSTEST_DEBUG_NOBP"] = "1", - ["VSTEST_RUNNER_DEBUG_ATTACHVS"] = "1", - ["VSTEST_HOST_DEBUG_ATTACHVS"] = "1", + ["VSTEST_RUNNER_DEBUG_ATTACHVS"] = "0", + ["VSTEST_HOST_DEBUG_ATTACHVS"] = "0", ["VSTEST_DATACOLLECTOR_DEBUG_ATTACHVS"] = "0", }; diff --git a/playground/TestPlatform.Playground/Program.cs b/playground/TestPlatform.Playground/Program.cs index 066ec4e026..142b324cb3 100644 --- a/playground/TestPlatform.Playground/Program.cs +++ b/playground/TestPlatform.Playground/Program.cs @@ -35,6 +35,7 @@ static void Main() var thisAssemblyPath = Assembly.GetEntryAssembly()!.Location; var here = Path.GetDirectoryName(thisAssemblyPath)!; + var playground = Path.GetFullPath(Path.Combine(here, "..", "..", "..", "..")); var console = Path.Combine(here, "vstest.console", "netfx", "vstest.console.exe"); @@ -87,9 +88,8 @@ static void Main() """; var sources = new[] { - "S:\\t\\nunit9\\bin\\Debug\\net9.0\\nunit9.dll" - //Path.Combine(playground, "bin", "MSTest1", "Debug", "net472", "MSTest1.dll"), - //Path.Combine(playground, "bin", "MSTest2", "Debug", "net472", "MSTest2.dll"), + Path.Combine(playground, "bin", "MSTest1", "Debug", "net472", "MSTest1.dll"), + Path.Combine(playground, "bin", "MSTest2", "Debug", "net472", "MSTest2.dll"), // The built in .NET projects don't now work right now in Playground, there is some conflict with Arcade. // But if you create one outside of Playground it will work. //Path.Combine(playground, "bin", "MSTest1", "Debug", "net7.0", "MSTest1.dll"),