Skip to content

Commit c393de4

Browse files
bergmeisterJamesWTruher
authored andcommitted
Fix Ubuntu build and runspace test (#1340)
* try old bootstrap mechanism * disable other builds * Tidy up and fix test
1 parent dcd533f commit c393de4

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

Tests/Engine/Helper.tests.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Describe "Test Directed Graph" {
3030
Context "Runspaces should be disposed" {
3131
It "Running analyzer 100 times should only create a limited number of runspaces" -Skip:$($PSVersionTable.PSVersion.Major -le 4) {
3232
$null = 1..100 | ForEach-Object { Invoke-ScriptAnalyzer -ScriptDefinition 'gci' }
33-
(Get-Runspace).Count | Should -BeLessOrEqual 10 -Because 'Number of Runspaces should not exceed size of runspace pool cache in CommandInfoCache'
33+
(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'
3434
}
3535
}
3636
}

tools/appveyor.psm1

+31-5
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,38 @@ function Invoke-AppVeyorInstall {
3131
Install-Module -Name platyPS -Force -Scope CurrentUser -RequiredVersion $platyPSVersion -Repository PSGallery
3232
}
3333

34-
# the build script sorts out the problems of WMF4 and earlier versions of dotnet CLI
34+
# 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
3535
Write-Verbose -Verbose "Installing required .Net CORE SDK"
36-
Write-Verbose "& $buildScriptDir/build.ps1 -bootstrap"
37-
$buildScriptDir = (Resolve-Path "$PSScriptRoot/..").Path
38-
& "$buildScriptDir/build.ps1" -bootstrap
39-
$Global:LASTEXITCODE = $LASTEXITCODE = 0 # needed to avoid a premature abortion of the AppVeyor Ubuntu build
36+
# the legacy WMF4 image only has the old preview SDKs of dotnet
37+
$globalDotJson = Get-Content (Join-Path $PSScriptRoot '..\global.json') -Raw | ConvertFrom-Json
38+
$requiredDotNetCoreSDKVersion = $globalDotJson.sdk.version
39+
if ($PSVersionTable.PSVersion.Major -gt 4) {
40+
$requiredDotNetCoreSDKVersionPresent = (dotnet --list-sdks) -match $requiredDotNetCoreSDKVersion
41+
}
42+
else {
43+
# WMF 4 image has old SDK that does not have --list-sdks parameter
44+
$requiredDotNetCoreSDKVersionPresent = (dotnet --version).StartsWith($requiredDotNetCoreSDKVersion)
45+
}
46+
if (-not $requiredDotNetCoreSDKVersionPresent) {
47+
Write-Verbose -Verbose "Installing required .Net CORE SDK $requiredDotNetCoreSDKVersion"
48+
$originalSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol
49+
try {
50+
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
51+
if ($IsLinux -or $isMacOS) {
52+
Invoke-WebRequest 'https://dot.net/v1/dotnet-install.sh' -OutFile dotnet-install.sh
53+
bash dotnet-install.sh --version $requiredDotNetCoreSDKVersion
54+
[System.Environment]::SetEnvironmentVariable('PATH', "/home/appveyor/.dotnet$([System.IO.Path]::PathSeparator)$PATH")
55+
}
56+
else {
57+
Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile dotnet-install.ps1
58+
.\dotnet-install.ps1 -Version $requiredDotNetCoreSDKVersion
59+
}
60+
}
61+
finally {
62+
[Net.ServicePointManager]::SecurityProtocol = $originalSecurityProtocol
63+
Remove-Item .\dotnet-install.*
64+
}
65+
}
4066
}
4167

4268
# Implements AppVeyor 'test_script' step

0 commit comments

Comments
 (0)