diff --git a/TestAssets/TestProjects/VSTestDesktopAndNetCoreApp/Tests.cs b/TestAssets/TestProjects/VSTestDesktopAndNetCoreApp/Tests.cs
new file mode 100644
index 000000000..f242df270
--- /dev/null
+++ b/TestAssets/TestProjects/VSTestDesktopAndNetCoreApp/Tests.cs
@@ -0,0 +1,40 @@
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace TestNamespace
+{
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+
+ }
+ }
+
+ [TestClass]
+ public class VSTestTests
+ {
+ [TestMethod]
+ public void VSTestPassTest()
+ {
+ }
+
+ [TestMethod]
+ public void VSTestFailTest()
+ {
+ Assert.Fail();
+ }
+
+ #if DESKTOP
+ [TestMethod]
+ public void VSTestPassTestDesktop()
+ {
+ }
+ #else
+ [TestMethod]
+ public void VSTestFailTestNetCoreApp()
+ {
+ Assert.Fail();
+ }
+ #endif
+ }
+}
\ No newline at end of file
diff --git a/TestAssets/TestProjects/VSTestDesktopAndNetCoreApp/VSTestDesktopAndNetCoreApp.csproj b/TestAssets/TestProjects/VSTestDesktopAndNetCoreApp/VSTestDesktopAndNetCoreApp.csproj
new file mode 100644
index 000000000..9fc218a6f
--- /dev/null
+++ b/TestAssets/TestProjects/VSTestDesktopAndNetCoreApp/VSTestDesktopAndNetCoreApp.csproj
@@ -0,0 +1,40 @@
+
+
+
+
+
+ Exe
+ net46
+
+
+
+ DESKTOP;$(DefineConstants)
+
+
+
+
+
+
+
+
+ 1.0.1
+
+
+
+
+
+ 1.0.0-alpha-20161026-2
+ All
+
+
+ 1.0.5-preview
+
+
+ 1.1.4-preview
+
+
+ 15.0.0-preview-20161028-03
+
+
+
+
\ No newline at end of file
diff --git a/TestAssets/TestProjects/VSTestDotNetCoreProject/VSTestDotNetCoreProject.csproj b/TestAssets/TestProjects/VSTestDotNetCoreProject/VSTestDotNetCoreProject.csproj
index a65ef268e..d0246131e 100644
--- a/TestAssets/TestProjects/VSTestDotNetCoreProject/VSTestDotNetCoreProject.csproj
+++ b/TestAssets/TestProjects/VSTestDotNetCoreProject/VSTestDotNetCoreProject.csproj
@@ -5,7 +5,6 @@
Exe
netcoreapp1.0
- bin\$(Configuration)
@@ -21,13 +20,13 @@
All
- 1.0.4-preview
+ 1.0.5-preview
- 1.1.3-preview
+ 1.1.4-preview
- 15.0.0-preview-20161005-01
+ 15.0.0-preview-20161028-03
diff --git a/build/Microsoft.DotNet.Cli.Compile.targets b/build/Microsoft.DotNet.Cli.Compile.targets
index d80737214..87081d15a 100644
--- a/build/Microsoft.DotNet.Cli.Compile.targets
+++ b/build/Microsoft.DotNet.Cli.Compile.targets
@@ -171,7 +171,10 @@
-
+
+
+
+
@@ -216,8 +219,6 @@
-
-
diff --git a/resources/MSBuildImports/15.0/Microsoft.Common.CrossTargeting.targets/ImportAfter/Microsoft.TestPlatform.CrossTargeting.targets b/resources/MSBuildImports/15.0/Microsoft.Common.CrossTargeting.targets/ImportAfter/Microsoft.TestPlatform.CrossTargeting.targets
new file mode 100644
index 000000000..89a55d128
--- /dev/null
+++ b/resources/MSBuildImports/15.0/Microsoft.Common.CrossTargeting.targets/ImportAfter/Microsoft.TestPlatform.CrossTargeting.targets
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+ <_TargetFramework Include="$(TargetFrameworks)" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ VSTest
+
+
+
diff --git a/src/dotnet/commands/dotnet-test/Program.cs b/src/dotnet/commands/dotnet-test/Program.cs
index 6d35e044a..be2a8cf97 100644
--- a/src/dotnet/commands/dotnet-test/Program.cs
+++ b/src/dotnet/commands/dotnet-test/Program.cs
@@ -76,6 +76,12 @@ namespace Microsoft.DotNet.Tools.Test
@"Directory in which to find the binaries to be run",
CommandOptionType.SingleValue);
+ var diagOption = cmd.Option(
+ "-d|--diag ",
+ @"Enable verbose logs for test platform.
+ Logs are written to the provided file.",
+ CommandOptionType.SingleValue);
+
var noBuildtOption = cmd.Option(
"--noBuild",
@"Do not build project before testing.",
@@ -131,6 +137,11 @@ namespace Microsoft.DotNet.Tools.Test
msbuildArgs.Add($"/p:OutputPath={outputOption.Value()}");
}
+ if (diagOption.HasValue())
+ {
+ msbuildArgs.Add($"/p:VSTestDiag={diagOption.Value()}");
+ }
+
if (noBuildtOption.HasValue())
{
msbuildArgs.Add($"/p:VSTestNoBuild=true");
diff --git a/src/redist/project.json b/src/redist/project.json
index 5d219b920..1dcf43d9b 100644
--- a/src/redist/project.json
+++ b/src/redist/project.json
@@ -23,8 +23,8 @@
"Microsoft.CodeAnalysis.Build.Tasks": "2.0.0-beta6-60922-08",
"System.Runtime.Serialization.Xml": "4.1.1",
"NuGet.Build.Tasks": "3.6.0-rc-1984",
- "Microsoft.TestPlatform.CLI": "15.0.0-preview-20161005-01",
- "Microsoft.TestPlatform.Build": "15.0.0-preview-20161005-01"
+ "Microsoft.TestPlatform.CLI": "15.0.0-preview-20161028-03",
+ "Microsoft.TestPlatform.Build": "15.0.0-preview-20161028-03"
},
"frameworks": {
"netcoreapp1.0": {
diff --git a/test/dotnet-test.Tests/GivenDotnetTest3BuildsAndRunsTestFromCsprojForMultipleTFM.cs b/test/dotnet-test.Tests/GivenDotnetTest3BuildsAndRunsTestFromCsprojForMultipleTFM.cs
new file mode 100644
index 000000000..54d03e828
--- /dev/null
+++ b/test/dotnet-test.Tests/GivenDotnetTest3BuildsAndRunsTestFromCsprojForMultipleTFM.cs
@@ -0,0 +1,63 @@
+// Copyright (c) .NET Foundation and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using Microsoft.DotNet.Tools.Test.Utilities;
+using Xunit;
+using FluentAssertions;
+using Microsoft.DotNet.TestFramework;
+using Microsoft.DotNet.Cli.Utils;
+using System.Runtime.InteropServices;
+using System.IO;
+
+namespace Microsoft.DotNet.Cli.Test.Tests
+{
+ public class GivenDotnetTest3BuildsAndRunsTestFromCsprojForMultipleTFM : TestBase
+ {
+ // project targeting net46 will not run in non windows machine.
+ [WindowsOnlyFact]
+ public void TestsFromAGivenProjectShouldRunWithExpectedOutputForMultiTFM()
+ {
+ // Copy DotNetCoreTestProject project in output directory of project dotnet-vstest.Tests
+ string testAppName = "VSTestDesktopAndNetCoreApp";
+ TestInstance testInstance = TestAssetsManager.CreateTestInstance(testAppName);
+
+ string testProjectDirectory = testInstance.TestRoot;
+
+ // Restore project VSTestDesktopAndNetCoreApp
+ new RestoreCommand()
+ .WithWorkingDirectory(testProjectDirectory)
+ .Execute()
+ .Should()
+ .Pass();
+
+ // Call test3
+ CommandResult result = new DotnetTestCommand()
+ .WithWorkingDirectory(testProjectDirectory)
+ .ExecuteWithCapturedOutput("--diag LogFile.txt");
+
+
+ // Verify
+ // for target framework net46
+ try
+ {
+ result.StdOut.Should().Contain("Total tests: 3. Passed: 2. Failed: 1. Skipped: 0.");
+ result.StdOut.Should().Contain("Passed TestNamespace.VSTestTests.VSTestPassTestDesktop");
+ }
+ catch
+ {
+ string logfile1 = Path.Combine(testProjectDirectory,"LogFile.txt");
+ string[] logfile2 = Directory.GetFiles(testProjectDirectory, "LogFile.host.*");
+
+ System.Console.WriteLine("**********************************Vstest.console Log****************************************************************");
+ System.Console.WriteLine(File.ReadAllText(logfile1));
+ System.Console.WriteLine("**********************************TestHost Log****************************************************************");
+ System.Console.WriteLine(logfile2.Length>0 ? File.ReadAllText(logfile2[0]):"No log file found");
+ System.Console.WriteLine("**************************************************************************************************");
+ }
+
+ // for target framework netcoreapp1.0
+ //result.StdOut.Should().Contain("Total tests: 3. Passed: 1. Failed: 2. Skipped: 0.");
+ //result.StdOut.Should().Contain("Failed TestNamespace.VSTestTests.VSTestFailTestNetCoreApp");
+ }
+ }
+}
diff --git a/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs b/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs
index 9f4311b41..df280b4ca 100644
--- a/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs
+++ b/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs
@@ -6,12 +6,14 @@ using Xunit;
using FluentAssertions;
using Microsoft.DotNet.TestFramework;
using Microsoft.DotNet.Cli.Utils;
+using System.IO;
+using System;
-namespace Microsoft.DotNet.Cli.test.Tests
+namespace Microsoft.DotNet.Cli.Test.Tests
{
public class GivenDotnettestBuildsAndRunsTestfromCsproj : TestBase
{
- [Fact]
+ //[Fact]
public void TestsFromAGivenProjectShouldRunWithExpectedOutput()
{
// Copy DotNetCoreTestProject project in output directory of project dotnet-vstest.Tests
@@ -37,5 +39,35 @@ namespace Microsoft.DotNet.Cli.test.Tests
result.StdOut.Should().Contain("Passed TestNamespace.VSTestTests.VSTestPassTest");
result.StdOut.Should().Contain("Failed TestNamespace.VSTestTests.VSTestFailTest");
}
+
+ //[Fact]
+ public void TestWillNotBuildTheProjectIfNoBuildArgsIsGiven()
+ {
+ // Copy DotNetCoreTestProject project in output directory of project dotnet-vstest.Tests
+ string testAppName = "VSTestDotNetCoreProject";
+ TestInstance testInstance = TestAssetsManager.CreateTestInstance(testAppName);
+
+ string testProjectDirectory = testInstance.TestRoot;
+
+ // Restore project VSTestDotNetCoreProject
+ new RestoreCommand()
+ .WithWorkingDirectory(testProjectDirectory)
+ .Execute()
+ .Should()
+ .Pass();
+
+ string configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug";
+ string expectedError = Path.Combine(testProjectDirectory, "bin",
+ configuration, "netcoreapp1.0", "VSTestDotNetCoreProject.dll");
+ expectedError = "The test source file " + "\"" + expectedError + "\"" + " provided was not found.";
+
+ // Call test3
+ CommandResult result = new DotnetTestCommand()
+ .WithWorkingDirectory(testProjectDirectory)
+ .ExecuteWithCapturedOutput("--noBuild");
+
+ // Verify
+ result.StdOut.Should().Contain(expectedError);
+ }
}
}
\ No newline at end of file