diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index ca95d72..d15e51b 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -74,7 +74,10 @@ jobs:
-prepareMachine
$(_BuildArgs)
displayName: Build and Publish
-
+
+ - script: test.cmd
+ displayName: Test
+
- ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
- task: ms-vseng.MicroBuildTasks.4305a8de-ba66-4d8b-b2d1-0dc4ecbbf5e8.MicroBuildUploadVstsDropFolder@1
displayName: Upload Azure DevOps Drop
diff --git a/eng/configure-toolset.ps1 b/eng/configure-toolset.ps1
new file mode 100644
index 0000000..ba86d5d
--- /dev/null
+++ b/eng/configure-toolset.ps1
@@ -0,0 +1,5 @@
+# We can't use already installed dotnet cli since we need to install additional shared runtimes.
+# We could potentially try to find an existing installation that has all the required runtimes,
+# but it's unlikely one will be available.
+
+$script:useInstalledDotNetCli = $false
\ No newline at end of file
diff --git a/eng/restore-toolset.ps1 b/eng/restore-toolset.ps1
new file mode 100644
index 0000000..354d02e
--- /dev/null
+++ b/eng/restore-toolset.ps1
@@ -0,0 +1,35 @@
+function InitializeCustomSDKToolset {
+
+ if (-not $restore) {
+ return
+ }
+
+ # The following frameworks and tools are used only for testing.
+ # Do not attempt to install them in source build.
+ if ($env:DotNetBuildFromSource -eq "true") {
+ return
+ }
+
+ $cli = InitializeDotnetCli -install:$true
+ InstallDotNetSharedFramework "1.0.5"
+ InstallDotNetSharedFramework "1.1.2"
+ InstallDotNetSharedFramework "2.1.0"
+ InstallDotNetSharedFramework "2.2.1"
+
+}
+
+function InstallDotNetSharedFramework([string]$version) {
+ $dotnetRoot = $env:DOTNET_INSTALL_DIR
+ $fxDir = Join-Path $dotnetRoot "shared\Microsoft.NETCore.App\$version"
+
+ if (!(Test-Path $fxDir)) {
+ $installScript = GetDotNetInstallScript $dotnetRoot
+ & $installScript -Version $version -InstallDir $dotnetRoot -Runtime "dotnet"
+
+ if($lastExitCode -ne 0) {
+ throw "Failed to install shared Framework $version to '$dotnetRoot' (exit code '$lastExitCode')."
+ }
+ }
+}
+
+InitializeCustomSDKToolset
\ No newline at end of file
diff --git a/test.cmd b/test.cmd
new file mode 100644
index 0000000..8bc9dcb
--- /dev/null
+++ b/test.cmd
@@ -0,0 +1,3 @@
+@echo off
+.dotnet\dotnet test test\Microsoft.TestTemplates.AcceptanceTests.sln --logger:trx
+exit /b %ErrorLevel%
diff --git a/test/Microsoft.TestTemplates.AcceptanceTests/IntegrationTestBase.cs b/test/Microsoft.TestTemplates.AcceptanceTests/IntegrationTestBase.cs
index 331cc56..7424168 100644
--- a/test/Microsoft.TestTemplates.AcceptanceTests/IntegrationTestBase.cs
+++ b/test/Microsoft.TestTemplates.AcceptanceTests/IntegrationTestBase.cs
@@ -6,6 +6,8 @@ namespace Microsoft.TestTemplates.AcceptanceTests
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Diagnostics;
+ using System.IO;
+ using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
@@ -25,10 +27,12 @@ namespace Microsoft.TestTemplates.AcceptanceTests
{
}
+ public object PathEnvironment { get; private set; }
+
///
- /// Invokes vstest.console with specified arguments.
+ /// Invokes dotnet with specified arguments.
///
- /// Arguments provided to vstest.console.exe
+ /// Arguments provided to dotnet.exe
public void InvokeDotnetTest(string arguments)
{
this.Execute(arguments, out this.standardTestOutput, out this.standardTestError, out this.runnerExitCode);
@@ -82,6 +86,20 @@ namespace Microsoft.TestTemplates.AcceptanceTests
}
}
+ private string GetDotnetExePath()
+ {
+ var currentDllPath = Path.GetDirectoryName(Assembly.GetAssembly(typeof(IntegrationTestBase)).Location);
+ string[] paths = currentDllPath.Split("\\artifacts");
+ if (paths.Length == 2)
+ {
+ var dotnetPath = Path.Combine(paths[0], ".dotnet", "dotnet.exe");
+ if (File.Exists(dotnetPath))
+ return dotnetPath;
+ }
+
+ return "dotnet";
+ }
+
private void Execute(string args, out string stdOut, out string stdError, out int exitCode)
{
this.arguments = args;
@@ -89,7 +107,7 @@ namespace Microsoft.TestTemplates.AcceptanceTests
using (Process dotnet = new Process())
{
Console.WriteLine("IntegrationTestBase.Execute: Starting dotnet.exe");
- dotnet.StartInfo.FileName = "dotnet.exe";
+ dotnet.StartInfo.FileName = GetDotnetExePath();
dotnet.StartInfo.Arguments = "test " + args;
dotnet.StartInfo.UseShellExecute = false;
dotnet.StartInfo.RedirectStandardError = true;
@@ -112,7 +130,7 @@ namespace Microsoft.TestTemplates.AcceptanceTests
dotnet.BeginErrorReadLine();
if (!dotnet.WaitForExit(80 * 1000))
{
- Console.WriteLine("IntegrationTestBase.Execute: Timed out waiting for vstest.console.exe. Terminating the process.");
+ Console.WriteLine("IntegrationTestBase.Execute: Timed out waiting for dotnet.exe. Terminating the process.");
dotnet.Kill();
}
else
@@ -131,7 +149,7 @@ namespace Microsoft.TestTemplates.AcceptanceTests
Console.WriteLine("IntegrationTestBase.Execute: stdError = {0}", stdError);
Console.WriteLine("IntegrationTestBase.Execute: stdOut = {0}", stdOut);
- Console.WriteLine("IntegrationTestBase.Execute: Stopped vstest.console.exe. Exit code = {0}", exitCode);
+ Console.WriteLine("IntegrationTestBase.Execute: Stopped dotnet.exe. Exit code = {0}", exitCode);
}
}
diff --git a/test/Microsoft.TestTemplates.AcceptanceTests/Microsoft.TestTemplates.AcceptanceTests.csproj b/test/Microsoft.TestTemplates.AcceptanceTests/Microsoft.TestTemplates.AcceptanceTests.csproj
index 7790151..6c9737e 100644
--- a/test/Microsoft.TestTemplates.AcceptanceTests/Microsoft.TestTemplates.AcceptanceTests.csproj
+++ b/test/Microsoft.TestTemplates.AcceptanceTests/Microsoft.TestTemplates.AcceptanceTests.csproj
@@ -2,12 +2,11 @@
netcoreapp2.1
-
+ true
false
-