Adding configure and restore script to install all the relevant runtimes.
Fixing the code to get the correct path to the dotnet
This commit is contained in:
Родитель
35659cb8bf
Коммит
46137af8dc
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -0,0 +1,3 @@
|
|||
@echo off
|
||||
.dotnet\dotnet test test\Microsoft.TestTemplates.AcceptanceTests.sln --logger:trx
|
||||
exit /b %ErrorLevel%
|
|
@ -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; }
|
||||
|
||||
/// <summary>
|
||||
/// Invokes <c>vstest.console</c> with specified arguments.
|
||||
/// Invokes <c>dotnet</c> with specified arguments.
|
||||
/// </summary>
|
||||
/// <param name="arguments">Arguments provided to <c>vstest.console</c>.exe</param>
|
||||
/// <param name="arguments">Arguments provided to <c>dotnet</c>.exe</param>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,12 +2,11 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
|
||||
<IsTestProject>true</IsTestProject>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" />
|
||||
</ItemGroup>
|
||||
|
|
Загрузка…
Ссылка в новой задаче