diff --git a/src/Adapter/MSTestAdapter.PlatformServices/Services/TestDeployment.cs b/src/Adapter/MSTestAdapter.PlatformServices/Services/TestDeployment.cs index 2fc480dc1e..87858290dc 100644 --- a/src/Adapter/MSTestAdapter.PlatformServices/Services/TestDeployment.cs +++ b/src/Adapter/MSTestAdapter.PlatformServices/Services/TestDeployment.cs @@ -127,6 +127,7 @@ public bool Deploy(IEnumerable testCases, IRunContext? runContext, IFr return false; } +#if NETFRAMEWORK string? firstTestSource = testCases.FirstOrDefault()?.Source; RunDirectories = _deploymentUtility.CreateDeploymentDirectories(runContext, firstTestSource); @@ -136,6 +137,16 @@ public bool Deploy(IEnumerable testCases, IRunContext? runContext, IFr { return false; } +#else + // On .NET Core, avoid creating empty deployment folders when no deployment items are used. + if (!hasDeploymentItems) + { + return false; + } + + string? firstTestSource = testCases.FirstOrDefault()?.Source; + RunDirectories = _deploymentUtility.CreateDeploymentDirectories(runContext, firstTestSource); +#endif // Object model currently does not have support for SuspendCodeCoverage. We can remove this once support is added #if NETFRAMEWORK diff --git a/test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Services/TestDeploymentTests.cs b/test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Services/TestDeploymentTests.cs index 4ac9f1a50c..5709e26406 100644 --- a/test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Services/TestDeploymentTests.cs +++ b/test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Services/TestDeploymentTests.cs @@ -219,8 +219,12 @@ public void DeployShouldReturnFalseWhenDeploymentEnabledSetToFalseAndHasNoDeploy // Deployment should not happen testDeployment.Deploy(new List { testCase }, null, null!).Should().BeFalse(); - // Deployment directories should get created + // Deployment directories should get created on .NET Framework for compat, but not on .NET Core +#if NETFRAMEWORK testDeployment.GetDeploymentDirectory().Should().NotBeNull(); +#else + testDeployment.GetDeploymentDirectory().Should().BeNull(); +#endif } public void DeployShouldReturnFalseWhenDeploymentEnabledSetToTrueButHasNoDeploymentItems() @@ -242,8 +246,12 @@ public void DeployShouldReturnFalseWhenDeploymentEnabledSetToTrueButHasNoDeploym // Deployment should not happen testDeployment.Deploy(new List { testCase }, null, null!).Should().BeFalse(); - // Deployment directories should get created + // Deployment directories should get created on .NET Framework for compat, but not on .NET Core +#if NETFRAMEWORK testDeployment.GetDeploymentDirectory().Should().NotBeNull(); +#else + testDeployment.GetDeploymentDirectory().Should().BeNull(); +#endif } // TODO: This test has to have mocks. It actually deploys stuff and we cannot assume that all the dependencies get copied over to bin\debug.