diff --git a/Tests/Engine/Helper.tests.ps1 b/Tests/Engine/Helper.tests.ps1 index 3217e686e..bd33bfb88 100644 --- a/Tests/Engine/Helper.tests.ps1 +++ b/Tests/Engine/Helper.tests.ps1 @@ -30,7 +30,7 @@ Describe "Test Directed Graph" { Context "Runspaces should be disposed" { It "Running analyzer 100 times should only create a limited number of runspaces" -Skip:$($PSVersionTable.PSVersion.Major -le 4) { $null = 1..100 | ForEach-Object { Invoke-ScriptAnalyzer -ScriptDefinition 'gci' } - (Get-Runspace).Count | Should -BeLessOrEqual 10 -Because 'Number of Runspaces should not exceed size of runspace pool cache in CommandInfoCache' + (Get-Runspace).Count | Should -BeLessOrEqual 11 -Because 'Number of Runspaces should not exceed size of runspace pool cache (10) plus the the default runspace pool (1) in CommandInfoCache' } } } diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 745e2410f..6323ae953 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -31,12 +31,38 @@ function Invoke-AppVeyorInstall { Install-Module -Name platyPS -Force -Scope CurrentUser -RequiredVersion $platyPSVersion -Repository PSGallery } - # the build script sorts out the problems of WMF4 and earlier versions of dotnet CLI + # Do not use 'build.ps1 -bootstrap' option for bootstraping the .Net SDK as it does not work well in CI with the AppVeyor Ubuntu image Write-Verbose -Verbose "Installing required .Net CORE SDK" - Write-Verbose "& $buildScriptDir/build.ps1 -bootstrap" - $buildScriptDir = (Resolve-Path "$PSScriptRoot/..").Path - & "$buildScriptDir/build.ps1" -bootstrap - $Global:LASTEXITCODE = $LASTEXITCODE = 0 # needed to avoid a premature abortion of the AppVeyor Ubuntu build + # the legacy WMF4 image only has the old preview SDKs of dotnet + $globalDotJson = Get-Content (Join-Path $PSScriptRoot '..\global.json') -Raw | ConvertFrom-Json + $requiredDotNetCoreSDKVersion = $globalDotJson.sdk.version + if ($PSVersionTable.PSVersion.Major -gt 4) { + $requiredDotNetCoreSDKVersionPresent = (dotnet --list-sdks) -match $requiredDotNetCoreSDKVersion + } + else { + # WMF 4 image has old SDK that does not have --list-sdks parameter + $requiredDotNetCoreSDKVersionPresent = (dotnet --version).StartsWith($requiredDotNetCoreSDKVersion) + } + if (-not $requiredDotNetCoreSDKVersionPresent) { + Write-Verbose -Verbose "Installing required .Net CORE SDK $requiredDotNetCoreSDKVersion" + $originalSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol + try { + [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 + if ($IsLinux -or $isMacOS) { + Invoke-WebRequest 'https://dot.net/v1/dotnet-install.sh' -OutFile dotnet-install.sh + bash dotnet-install.sh --version $requiredDotNetCoreSDKVersion + [System.Environment]::SetEnvironmentVariable('PATH', "/home/appveyor/.dotnet$([System.IO.Path]::PathSeparator)$PATH") + } + else { + Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile dotnet-install.ps1 + .\dotnet-install.ps1 -Version $requiredDotNetCoreSDKVersion + } + } + finally { + [Net.ServicePointManager]::SecurityProtocol = $originalSecurityProtocol + Remove-Item .\dotnet-install.* + } + } } # Implements AppVeyor 'test_script' step