diff --git a/eng/helix/content/InstallAppRuntime.ps1 b/eng/helix/content/InstallAppRuntime.ps1 deleted file mode 100644 index 5307a09e60..0000000000 --- a/eng/helix/content/InstallAppRuntime.ps1 +++ /dev/null @@ -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 diff --git a/eng/helix/content/InstallAspNetRef.ps1 b/eng/helix/content/InstallAspNetRef.ps1 deleted file mode 100644 index d5a4d2a9c6..0000000000 --- a/eng/helix/content/InstallAspNetRef.ps1 +++ /dev/null @@ -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 diff --git a/eng/helix/content/RunTests/Program.cs b/eng/helix/content/RunTests/Program.cs index f9d3ec2752..df47e1bb8b 100644 --- a/eng/helix/content/RunTests/Program.cs +++ b/eng/helix/content/RunTests/Program.cs @@ -23,6 +23,10 @@ namespace RunTests { keepGoing = await runner.InstallAspNetAppIfNeededAsync(); } + if (keepGoing) + { + keepGoing = runner.InstallAspNetRefIfNeeded(); + } runner.DisplayContents(); diff --git a/eng/helix/content/RunTests/RunTestsOptions.cs b/eng/helix/content/RunTests/RunTestsOptions.cs index fcfdc84e42..7320cc66bc 100644 --- a/eng/helix/content/RunTests/RunTestsOptions.cs +++ b/eng/helix/content/RunTests/RunTestsOptions.cs @@ -50,6 +50,16 @@ namespace RunTests aliases: new string[] { "--ef" }, description: "The version of the EF tool to use") { Argument = new Argument(), Required = true }, + + new Option( + aliases: new string[] { "--aspnetruntime" }, + description: "The path to the aspnet runtime nupkg to install") + { Argument = new Argument(), Required = true }, + + new Option( + aliases: new string[] { "--aspnetref" }, + description: "The path to the aspnet ref nupkg to install") + { Argument = new Argument(), Required = true }, }; var parseResult = command.Parse(args); @@ -61,6 +71,8 @@ namespace RunTests options.Architecture = parseResult.ValueForOption("--arch"); options.Quarantined = parseResult.ValueForOption("--quarantined"); options.EfVersion = parseResult.ValueForOption("--ef"); + options.AspNetRuntime = parseResult.ValueForOption("--aspnetruntime"); + options.AspNetRef = parseResult.ValueForOption("--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;} diff --git a/eng/helix/content/RunTests/TestRunner.cs b/eng/helix/content/RunTests/TestRunner.cs index 2a9fadfb01..46da55bb78 100644 --- a/eng/helix/content/RunTests/TestRunner.cs +++ b/eng/helix/content/RunTests/TestRunner.cs @@ -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 CheckTestDiscoveryAsync() { try diff --git a/eng/helix/content/installappruntime.sh b/eng/helix/content/installappruntime.sh deleted file mode 100755 index 09a82953a9..0000000000 --- a/eng/helix/content/installappruntime.sh +++ /dev/null @@ -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 diff --git a/eng/helix/content/installaspnetref.sh b/eng/helix/content/installaspnetref.sh deleted file mode 100644 index 6ab719a09f..0000000000 --- a/eng/helix/content/installaspnetref.sh +++ /dev/null @@ -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 diff --git a/eng/helix/content/runtests.cmd b/eng/helix/content/runtests.cmd index 1078def35b..44d8b83c57 100644 --- a/eng/helix/content/runtests.cmd +++ b/eng/helix/content/runtests.cmd @@ -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 ) diff --git a/eng/helix/content/runtests.sh b/eng/helix/content/runtests.sh old mode 100755 new mode 100644 index d643d7c5bf..0a5742db39 --- a/eng/helix/content/runtests.sh +++ b/eng/helix/content/runtests.sh @@ -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 diff --git a/eng/targets/Helix.targets b/eng/targets/Helix.targets index 93b8feb54f..b2af0b0936 100644 --- a/eng/targets/Helix.targets +++ b/eng/targets/Helix.targets @@ -16,24 +16,8 @@ - + - - - - - - - - - - - - - - - - @@ -109,6 +93,7 @@ Usage: dotnet msbuild /t:Helix src/MyTestProject.csproj + @@ -130,8 +115,8 @@ Usage: dotnet msbuild /t:Helix src/MyTestProject.csproj $(TargetFileName) @(HelixPreCommand) @(HelixPostCommand) - call runtests.cmd $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests) $(DotnetEfPackageVersion) - ./runtests.sh $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests) $(DotnetEfPackageVersion) + call runtests.cmd $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests) $(DotnetEfPackageVersion) Microsoft.AspNetCore.App.Runtime.win-x64.$(AppRuntimeVersion).nupkg Microsoft.AspNetCore.App.Ref.$(AppRuntimeVersion).nupkg + ./runtests.sh $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests) $(DotnetEfPackageVersion) Microsoft.AspNetCore.App.Runtime.win-x64.$(AppRuntimeVersion).nupkg Microsoft.AspNetCore.App.Ref.$(AppRuntimeVersion).nupkg $(HelixCommand) $(HelixTimeout)