[Helix] Install aspnet runtime as part of test runner (#20693)
This commit is contained in:
parent
51f69a6bbb
commit
c16d3364d4
|
|
@ -1,53 +0,0 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Installs an AspNetCore shared framework on a machine
|
||||
.DESCRIPTION
|
||||
This script installs an AspNetCore shared framework on a machine
|
||||
.PARAMETER AppRuntimePath
|
||||
The path to the app runtime package to install.
|
||||
.PARAMETER InstallDir
|
||||
The directory to install the shared framework to.
|
||||
.PARAMETER Framework
|
||||
The framework directory to copy the shared framework from.
|
||||
.PARAMETER RuntimeIdentifier
|
||||
The runtime identifier for the shared framework.
|
||||
#>
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
$AppRuntimePath,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
$InstallDir,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
$Framework,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
$RuntimeIdentifier)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$ProgressPreference = 'SilentlyContinue' # Workaround PowerShell/PowerShell#2138
|
||||
|
||||
Set-StrictMode -Version 1
|
||||
|
||||
$zipPackage = [io.path]::ChangeExtension($AppRuntimePath, ".zip")
|
||||
Write-Host "Renaming to $zipPackage"
|
||||
Rename-Item -Path $AppRuntimePath -NewName $zipPackage
|
||||
if (Get-Command -Name 'Microsoft.PowerShell.Archive\Expand-Archive' -ErrorAction Ignore) {
|
||||
# Use built-in commands where possible as they are cross-plat compatible
|
||||
Microsoft.PowerShell.Archive\Expand-Archive -Path $zipPackage -DestinationPath ".\tmpRuntime" -Force
|
||||
}
|
||||
else {
|
||||
Remove-Item ".\tmpRuntime" -Recurse -ErrorAction Ignore
|
||||
# Fallback to old approach for old installations of PowerShell
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipPackage, ".\tmpRuntime")
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $InstallDir
|
||||
Write-Host "Copying *.txt to $InstallDir"
|
||||
Copy-Item -Path ".\tmpRuntime\*.txt" $InstallDir
|
||||
Write-Host "Copying managed files to $InstallDir"
|
||||
Copy-Item -Path ".\tmpRuntime\runtimes\$RuntimeIdentifier\lib\$Framework\*" $InstallDir
|
||||
Write-Host "Copying native files to $InstallDir"
|
||||
Copy-Item -Path ".\tmpRuntime\runtimes\$RuntimeIdentifier\native\*" $InstallDir
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Unzips an AspNetCore.App.Ref nupkg
|
||||
.DESCRIPTION
|
||||
This script unzips an AspNetCore.App.Ref nupkg
|
||||
.PARAMETER RefPath
|
||||
The path to the AspNetCore.App.Ref package to install.
|
||||
.PARAMETER InstallDir
|
||||
The directory to install to.
|
||||
#>
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
$RefPath,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
$InstallDir
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$ProgressPreference = 'SilentlyContinue' # Workaround PowerShell/PowerShell#2138
|
||||
|
||||
Set-StrictMode -Version 1
|
||||
|
||||
Write-Host "Extracting to $InstallDir"
|
||||
|
||||
$zipPackage = [io.path]::ChangeExtension($RefPath, ".zip")
|
||||
Write-Host "Renaming to $zipPackage"
|
||||
Rename-Item -Path $RefPath -NewName $zipPackage
|
||||
if (Get-Command -Name 'Microsoft.PowerShell.Archive\Expand-Archive' -ErrorAction Ignore) {
|
||||
# Use built-in commands where possible as they are cross-plat compatible
|
||||
Microsoft.PowerShell.Archive\Expand-Archive -Path $zipPackage -DestinationPath "$InstallDir" -Force
|
||||
}
|
||||
else {
|
||||
Remove-Item "$InstallDir" -Recurse -ErrorAction Ignore
|
||||
# Fallback to old approach for old installations of PowerShell
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipPackage, "$InstallDir")
|
||||
}
|
||||
|
||||
Get-ChildItem -Path "$InstallDir" -Recurse
|
||||
|
|
@ -23,6 +23,10 @@ namespace RunTests
|
|||
{
|
||||
keepGoing = await runner.InstallAspNetAppIfNeededAsync();
|
||||
}
|
||||
if (keepGoing)
|
||||
{
|
||||
keepGoing = runner.InstallAspNetRefIfNeeded();
|
||||
}
|
||||
|
||||
runner.DisplayContents();
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,16 @@ namespace RunTests
|
|||
aliases: new string[] { "--ef" },
|
||||
description: "The version of the EF tool to use")
|
||||
{ Argument = new Argument<string>(), Required = true },
|
||||
|
||||
new Option(
|
||||
aliases: new string[] { "--aspnetruntime" },
|
||||
description: "The path to the aspnet runtime nupkg to install")
|
||||
{ Argument = new Argument<string>(), Required = true },
|
||||
|
||||
new Option(
|
||||
aliases: new string[] { "--aspnetref" },
|
||||
description: "The path to the aspnet ref nupkg to install")
|
||||
{ Argument = new Argument<string>(), Required = true },
|
||||
};
|
||||
|
||||
var parseResult = command.Parse(args);
|
||||
|
|
@ -61,6 +71,8 @@ namespace RunTests
|
|||
options.Architecture = parseResult.ValueForOption<string>("--arch");
|
||||
options.Quarantined = parseResult.ValueForOption<bool>("--quarantined");
|
||||
options.EfVersion = parseResult.ValueForOption<string>("--ef");
|
||||
options.AspNetRuntime = parseResult.ValueForOption<string>("--aspnetruntime");
|
||||
options.AspNetRef = parseResult.ValueForOption<string>("--aspnetref");
|
||||
options.HELIX_WORKITEM_ROOT = Environment.GetEnvironmentVariable("HELIX_WORKITEM_ROOT");
|
||||
options.Path = Environment.GetEnvironmentVariable("PATH");
|
||||
options.DotnetRoot = Environment.GetEnvironmentVariable("DOTNET_ROOT");
|
||||
|
|
@ -70,6 +82,8 @@ namespace RunTests
|
|||
public string Target { get; set;}
|
||||
public string SdkVersion { get; set;}
|
||||
public string RuntimeVersion { get; set;}
|
||||
public string AspNetRuntime { get; set;}
|
||||
public string AspNetRef { get; set;}
|
||||
public string HelixQueue { get; set;}
|
||||
public string Architecture { get; set;}
|
||||
public bool Quarantined { get; set;}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.CommandLine;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
|
@ -91,18 +92,26 @@ namespace RunTests
|
|||
{
|
||||
try
|
||||
{
|
||||
Console.WriteLine("Checking for Microsoft.AspNetCore.App/");
|
||||
if (Directory.Exists("Microsoft.AspNetCore.App"))
|
||||
if (File.Exists(Options.AspNetRuntime))
|
||||
{
|
||||
var appRuntimePath = $"{Options.DotnetRoot}/shared/Microsoft.AspNetCore.App/{Options.RuntimeVersion}";
|
||||
Console.WriteLine($"Creating directory: {appRuntimePath}");
|
||||
Directory.CreateDirectory(appRuntimePath);
|
||||
Console.WriteLine($"Found Microsoft.AspNetCore.App/, copying to {appRuntimePath}");
|
||||
Console.WriteLine($"Set ASPNET_RUNTIME_PATH: {appRuntimePath}");
|
||||
EnvironmentVariables.Add("ASPNET_RUNTIME_PATH", appRuntimePath);
|
||||
foreach (var file in Directory.EnumerateFiles("Microsoft.AspNetCore.App", "*.*", SearchOption.AllDirectories))
|
||||
Console.WriteLine($"Found AspNetRuntime: {Options.AspNetRuntime}, extracting *.txt,json,dll to {appRuntimePath}");
|
||||
using (var archive = ZipFile.OpenRead(Options.AspNetRuntime))
|
||||
{
|
||||
File.Copy(file, Path.Combine(appRuntimePath, Path.GetFileName(file)), overwrite: true);
|
||||
foreach (var entry in archive.Entries)
|
||||
{
|
||||
// These are the only extensions that end up in the shared fx directory
|
||||
if (entry.Name.EndsWith(".txt", StringComparison.OrdinalIgnoreCase) ||
|
||||
entry.Name.EndsWith(".json", StringComparison.OrdinalIgnoreCase) ||
|
||||
entry.Name.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
entry.ExtractToFile(Path.Combine(appRuntimePath, entry.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DisplayContents(appRuntimePath);
|
||||
|
|
@ -135,7 +144,7 @@ namespace RunTests
|
|||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"No app runtime found, skipping...");
|
||||
Console.WriteLine($"No AspNetRuntime found: {Options.AspNetRuntime}, skipping...");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -146,6 +155,31 @@ namespace RunTests
|
|||
}
|
||||
}
|
||||
|
||||
public bool InstallAspNetRefIfNeeded()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(Options.AspNetRef))
|
||||
{
|
||||
var refPath = $"Microsoft.AspNetCore.App.Ref";
|
||||
Console.WriteLine($"Found AspNetRef: {Options.AspNetRef}, extracting to {refPath}");
|
||||
ZipFile.ExtractToDirectory(Options.AspNetRef, "Microsoft.AspNetCore.App.Ref");
|
||||
|
||||
DisplayContents(refPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"No AspNetRef found: {Options.AspNetRef}, skipping...");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine($"Exception in InstallAspNetRefIfNeeded: {e.ToString()}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> CheckTestDiscoveryAsync()
|
||||
{
|
||||
try
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Cause the script to fail if any subcommand fails
|
||||
set -e
|
||||
|
||||
appRuntimePath=$1
|
||||
output_dir=$2
|
||||
framework=$3
|
||||
rid=$4
|
||||
tmpDir=./tmpRuntime
|
||||
|
||||
echo "Installing shared framework from $appRuntimePath"
|
||||
cp $appRuntimePath sharedFx.zip
|
||||
|
||||
mkdir -p $tmpDir
|
||||
unzip sharedFx.zip -d $tmpDir
|
||||
mkdir -p $output_dir
|
||||
echo "Copying to $output_dir"
|
||||
cp $tmpDir/*.txt $output_dir
|
||||
cp $tmpDir/runtimes/$rid/lib/$framework/* $output_dir
|
||||
cp $tmpDir/runtimes/$rid/native/* $output_dir
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Cause the script to fail if any subcommand fails
|
||||
set -e
|
||||
|
||||
refPath=$1
|
||||
output_dir=$2
|
||||
tmpDir=./tmpRuntime
|
||||
|
||||
echo "Installing ref package from $refPath"
|
||||
cp $refPath sharedFx.zip
|
||||
|
||||
mkdir -p $output_dir
|
||||
echo "Unzip to $output_dir"
|
||||
unzip sharedFx.zip -d $output_dir
|
||||
|
|
@ -21,10 +21,10 @@ echo "Installing Runtime"
|
|||
powershell.exe -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -useb 'https://dot.net/v1/dotnet-install.ps1'))) -Architecture %$arch% -Runtime dotnet -Version %$runtimeVersion% -InstallDir %DOTNET_ROOT%"
|
||||
|
||||
set exit_code=0
|
||||
echo "Restore for RunTests..."
|
||||
echo "Restore: dotnet restore RunTests\RunTests.csproj --source https://api.nuget.org/v3/index.json --ignore-failed-sources..."
|
||||
dotnet restore RunTests\RunTests.csproj --source https://api.nuget.org/v3/index.json --ignore-failed-sources
|
||||
echo "Running tests..."
|
||||
dotnet run --project RunTests\RunTests.csproj -- --target %1 --sdk %2 --runtime %3 --queue %4 --arch %5 --quarantined %6 --ef %7
|
||||
echo "Running tests: dotnet run --project RunTests\RunTests.csproj -- --target %1 --sdk %2 --runtime %3 --queue %4 --arch %5 --quarantined %6 --ef %7 --aspnetruntime %8 --aspnetref %9..."
|
||||
dotnet run --project RunTests\RunTests.csproj -- --target %1 --sdk %2 --runtime %3 --queue %4 --arch %5 --quarantined %6 --ef %7 --aspnetruntime %8 --aspnetref %9
|
||||
if errorlevel 1 (
|
||||
set exit_code=1
|
||||
)
|
||||
|
|
|
|||
|
|
@ -86,10 +86,10 @@ fi
|
|||
sync
|
||||
|
||||
exit_code=0
|
||||
echo "Restore for RunTests..."
|
||||
echo "Restore: $DOTNET_ROOT/dotnet restore RunTests/RunTests.csproj --source https://api.nuget.org/v3/index.json --ignore-failed-sources..."
|
||||
$DOTNET_ROOT/dotnet restore RunTests/RunTests.csproj --source https://api.nuget.org/v3/index.json --ignore-failed-sources
|
||||
echo "Running tests..."
|
||||
$DOTNET_ROOT/dotnet run --project RunTests/RunTests.csproj -- --target $1 --sdk $2 --runtime $3 --queue $4 --arch $5 --quarantined $6 --ef $7
|
||||
echo "Running tests: $DOTNET_ROOT/dotnet run --project RunTests/RunTests.csproj -- --target $1 --sdk $2 --runtime $3 --queue $4 --arch $5 --quarantined $6 --ef $7 --aspnetruntime $8 --aspnetref $9..."
|
||||
$DOTNET_ROOT/dotnet run --project RunTests/RunTests.csproj -- --target $1 --sdk $2 --runtime $3 --queue $4 --arch $5 --quarantined $6 --ef $7 --aspnetruntime $8 --aspnetref $9
|
||||
exit_code=$?
|
||||
echo "Finished tests...exit_code=$exit_code"
|
||||
exit $exit_code
|
||||
|
|
|
|||
|
|
@ -16,24 +16,8 @@
|
|||
<HelixPreCommand Include="call RunPowershell.cmd InstallNode.ps1 $(NodeVersion) %25HELIX_CORRELATION_PAYLOAD%25\node\bin || exit /b 1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(IsHelixJob)' == 'true' AND '$(IsWindowsHelixQueue)' == 'true' AND '$(TestDependsOnAspNetRef)' == 'true' AND '$(IsTargetingPackBuilding)' == 'true'">
|
||||
<ItemGroup Condition="'$(IsHelixJob)' == 'true' AND '$(TestDependsOnAspNetRef)' == 'true' AND '$(IsTargetingPackBuilding)' == 'true'">
|
||||
<HelixContent Include="$(RepoRoot)artifacts\packages\Release\Shipping\Microsoft.AspNetCore.App.Ref.$(AppRuntimeVersion).nupkg" />
|
||||
<HelixPreCommand Include="call RunPowershell.cmd InstallAspNetRef.ps1 Microsoft.AspNetCore.App.Ref.$(AppRuntimeVersion).nupkg Microsoft.AspNetCore.App.Ref || exit /b 1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(IsHelixJob)' == 'true' AND '$(IsWindowsHelixQueue)' == 'false' AND '$(TestDependsOnAspNetRef)' == 'true' AND '$(IsTargetingPackBuilding)' == 'true'">
|
||||
<HelixContent Include="$(RepoRoot)artifacts\packages\Release\Shipping\Microsoft.AspNetCore.App.Ref.$(AppRuntimeVersion).nupkg" />
|
||||
<HelixPreCommand Include="./installaspnetref.sh Microsoft.AspNetCore.App.Ref.$(AppRuntimeVersion).nupkg Microsoft.AspNetCore.App.Ref || exit /b 1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(IsHelixJob)' == 'true' AND '$(IsWindowsHelixQueue)' == 'true' AND '$(TestDependsOnAspNetRuntime)' == 'true'">
|
||||
<HelixContent Include="$(RepoRoot)artifacts\packages\Release\Shipping\Microsoft.AspNetCore.App.Runtime.win-x64.$(AppRuntimeVersion).nupkg" />
|
||||
<HelixPreCommand Include="call RunPowershell.cmd InstallAppRuntime.ps1 Microsoft.AspNetCore.App.Runtime.win-x64.$(AppRuntimeVersion).nupkg Microsoft.AspNetCore.App netcoreapp5.0 win-x64 || exit /b 1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(IsHelixJob)' == 'true' AND '$(IsWindowsHelixQueue)' == 'false' AND '$(TestDependsOnAspNetRuntime)' == 'true'">
|
||||
<HelixContent Include="$(RepoRoot)artifacts\packages\Release\Shipping\Microsoft.AspNetCore.App.Runtime.win-x64.$(AppRuntimeVersion).nupkg" />
|
||||
<HelixPreCommand Include="./installappruntime.sh Microsoft.AspNetCore.App.Runtime.win-x64.$(AppRuntimeVersion).nupkg Microsoft.AspNetCore.App netcoreapp5.0 win-x64" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(IsHelixJob)' == 'true' AND '$(TestDependsOnAspNetRuntime)' == 'true'">
|
||||
|
|
@ -109,6 +93,7 @@ Usage: dotnet msbuild /t:Helix src/MyTestProject.csproj
|
|||
<ItemGroup>
|
||||
<HelixContent Include="$(OutputPath)/Microsoft.VisualStudio.TestPlatform.Extension.Xunit.Xml.TestAdapter.dll" />
|
||||
<HelixContent Include="$(OutputPath)/Microsoft.VisualStudio.TestPlatform.Extension.Xunit.Xml.TestLogger.dll" />
|
||||
<HelixContent Condition="'$(TestDependsOnAspNetRuntime)' == 'true'" Include="$(RepoRoot)artifacts\packages\Release\Shipping\Microsoft.AspNetCore.App.Runtime.win-x64.$(AppRuntimeVersion).nupkg" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
|
@ -130,8 +115,8 @@ Usage: dotnet msbuild /t:Helix src/MyTestProject.csproj
|
|||
<TestAssembly>$(TargetFileName)</TestAssembly>
|
||||
<PreCommands>@(HelixPreCommand)</PreCommands>
|
||||
<PostCommands>@(HelixPostCommand)</PostCommands>
|
||||
<Command Condition="$(IsWindowsHelixQueue)">call runtests.cmd $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests) $(DotnetEfPackageVersion)</Command>
|
||||
<Command Condition="!$(IsWindowsHelixQueue)">./runtests.sh $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests) $(DotnetEfPackageVersion)</Command>
|
||||
<Command Condition="$(IsWindowsHelixQueue)">call runtests.cmd $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests) $(DotnetEfPackageVersion) Microsoft.AspNetCore.App.Runtime.win-x64.$(AppRuntimeVersion).nupkg Microsoft.AspNetCore.App.Ref.$(AppRuntimeVersion).nupkg</Command>
|
||||
<Command Condition="!$(IsWindowsHelixQueue)">./runtests.sh $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests) $(DotnetEfPackageVersion) Microsoft.AspNetCore.App.Runtime.win-x64.$(AppRuntimeVersion).nupkg Microsoft.AspNetCore.App.Ref.$(AppRuntimeVersion).nupkg</Command>
|
||||
<Command Condition="$(HelixCommand) != ''">$(HelixCommand)</Command>
|
||||
<Timeout>$(HelixTimeout)</Timeout>
|
||||
</HelixWorkItem>
|
||||
|
|
|
|||
Loading…
Reference in New Issue