diff --git a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DotnetTestMSBuildOutputTests.cs b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DotnetTestMSBuildOutputTests.cs index 2a007ed8b3..3e613a599e 100644 --- a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DotnetTestMSBuildOutputTests.cs +++ b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DotnetTestMSBuildOutputTests.cs @@ -23,7 +23,7 @@ public void MSBuildLoggerCanBeEnabledByBuildPropertyAndDoesNotEatSpecialChars(Ru { SetTestEnvironment(_testEnvironment, runnerInfo); - var projectPath = GetIsolatedTestAsset("TerminalLoggerTestProject.csproj"); + var projectPath = GetIsolatedTestAsset("TerminalLoggerTestProject.csproj", runnerInfo.TargetFramework); // Forcing terminal logger so we can see the output when it is redirected InvokeDotnetTest($@"{projectPath} -tl:on -nodereuse:false /p:PackageVersion={IntegrationTestEnvironment.LatestLocallyBuiltNugetVersion}", workingDirectory: Path.GetDirectoryName(projectPath)); @@ -53,7 +53,7 @@ public void MSBuildLoggerCanBeDisabledByBuildProperty(RunnerInfo runnerInfo) { SetTestEnvironment(_testEnvironment, runnerInfo); - var projectPath = GetIsolatedTestAsset("TerminalLoggerTestProject.csproj"); + var projectPath = GetIsolatedTestAsset("TerminalLoggerTestProject.csproj", runnerInfo.TargetFramework); InvokeDotnetTest($@"{projectPath} -nodereuse:false /p:VsTestUseMSBuildOutput=false /p:PackageVersion={IntegrationTestEnvironment.LatestLocallyBuiltNugetVersion}", workingDirectory: Path.GetDirectoryName(projectPath)); // Check that we see the summary that is printed from the console logger, meaning the new output is disabled. @@ -73,7 +73,7 @@ public void MSBuildLoggerCanBeDisabledByEnvironmentVariableProperty(RunnerInfo r { SetTestEnvironment(_testEnvironment, runnerInfo); - var projectPath = GetIsolatedTestAsset("TerminalLoggerTestProject.csproj"); + var projectPath = GetIsolatedTestAsset("TerminalLoggerTestProject.csproj", runnerInfo.TargetFramework); InvokeDotnetTest($@"{projectPath} -nodereuse:false /p:PackageVersion={IntegrationTestEnvironment.LatestLocallyBuiltNugetVersion}", environmentVariables: new Dictionary { ["MSBUILDENSURESTDOUTFORTASKPROCESSES"] = "1" }, workingDirectory: Path.GetDirectoryName(projectPath)); // Check that we see the summary that is printed from the console logger, meaning the new output is disabled. diff --git a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DotnetTestTests.cs b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DotnetTestTests.cs index 338d6b6d0f..f0dca3004b 100644 --- a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DotnetTestTests.cs +++ b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DotnetTestTests.cs @@ -26,7 +26,7 @@ public void RunDotnetTestWithCsproj(RunnerInfo runnerInfo) { SetTestEnvironment(_testEnvironment, runnerInfo); - var projectPath = GetIsolatedTestAsset("SimpleTestProject.csproj"); + var projectPath = GetIsolatedTestAsset("SimpleTestProject.csproj", runnerInfo.TargetFramework); InvokeDotnetTest($@"{projectPath} -tl:off /p:VSTestNoLogo=false --logger:""Console;Verbosity=normal"" /p:PackageVersion={IntegrationTestEnvironment.LatestLocallyBuiltNugetVersion}", workingDirectory: Path.GetDirectoryName(projectPath)); // ensure our dev version is used @@ -60,7 +60,7 @@ public void RunDotnetTestWithCsprojPassInlineSettings(RunnerInfo runnerInfo) { SetTestEnvironment(_testEnvironment, runnerInfo); - var projectPath = GetIsolatedTestAsset("ParametrizedTestProject.csproj"); + var projectPath = GetIsolatedTestAsset("ParametrizedTestProject.csproj", runnerInfo.TargetFramework); InvokeDotnetTest($@"{projectPath} --logger:""Console;Verbosity=normal"" -tl:off /p:VSTestNoLogo=false /p:PackageVersion={IntegrationTestEnvironment.LatestLocallyBuiltNugetVersion} -- TestRunParameters.Parameter(name =\""weburl\"", value=\""http://localhost//def\"")", workingDirectory: Path.GetDirectoryName(projectPath)); // ensure our dev version is used diff --git a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/RunsettingsTests.cs b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/RunsettingsTests.cs index 4eec7dc7d0..4ad5e27d52 100644 --- a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/RunsettingsTests.cs +++ b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/RunsettingsTests.cs @@ -510,7 +510,7 @@ public void RunSettingsAreLoadedFromProject(RunnerInfo runnerInfo) SetTestEnvironment(_testEnvironment, runnerInfo); var projectName = "ProjectFileRunSettingsTestProject.csproj"; - var projectPath = GetIsolatedTestAsset(projectName); + var projectPath = GetIsolatedTestAsset(projectName, runnerInfo.TargetFramework); InvokeDotnetTest($@"{projectPath} /p:VSTestUseMSBuildOutput=false --logger:""Console;Verbosity=normal"" /p:PackageVersion={IntegrationTestEnvironment.LatestLocallyBuiltNugetVersion}", workingDirectory: Path.GetDirectoryName(projectPath)); ValidateSummaryStatus(0, 1, 0); diff --git a/test/Microsoft.TestPlatform.TestUtilities/AcceptanceTestBase.cs b/test/Microsoft.TestPlatform.TestUtilities/AcceptanceTestBase.cs index cee9d580a4..eb285985b8 100644 --- a/test/Microsoft.TestPlatform.TestUtilities/AcceptanceTestBase.cs +++ b/test/Microsoft.TestPlatform.TestUtilities/AcceptanceTestBase.cs @@ -4,6 +4,7 @@ using System; using System.IO; using System.Linq; +using System.Text.RegularExpressions; namespace Microsoft.TestPlatform.TestUtilities; @@ -137,7 +138,7 @@ public static string GetRunSettingsWithTargetFramework(string targetFramework) return runSettingsXml; } - protected string GetIsolatedTestAsset(string assetName) + protected string GetIsolatedTestAsset(string assetName, string targetFramework) { var projectPath = GetProjectFullPath(assetName); @@ -147,6 +148,13 @@ protected string GetIsolatedTestAsset(string assetName) if (file.Extension.Equals(".csproj", StringComparison.OrdinalIgnoreCase)) { + // Build just for the given tfm + var projFile = Path.Combine(TempDirectory.Path, Path.GetFileName(file.FullName)); + var csprojContent = File.ReadAllText(projFile); + csprojContent = Regex.Replace(csprojContent, ".*?", $"{targetFramework}"); + csprojContent = Regex.Replace(csprojContent, ".*?", $"{targetFramework}"); + File.WriteAllText(projFile, csprojContent); + string root = IntegrationTestEnvironment.RepoRootDirectory; var testAssetsRoot = Path.GetFullPath(Path.Combine(root, "test", "TestAssets"));