Skip to content

Commit 4767772

Browse files
committed
install pwsh for windows if required instead of skipping tests. Thanks for Ilya for the help to get that working
1 parent 511216c commit 4767772

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

appveyor.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ cache:
2121
install:
2222
- ps: if ($env:PowerShellEdition -eq 'WindowsPowerShell') { Import-Module .\tools\appveyor.psm1; Invoke-AppveyorInstall }
2323
- pwsh: if ($env:PowerShellEdition -eq 'PowerShellCore') { Import-Module .\tools\appveyor.psm1; Invoke-AppveyorInstall }
24+
- ps: |
25+
# Windows image still has version 6.0.0 of pwsh but 6.0.2 is required due to System.Management.Automation package https://github.com/appveyor/ci/issues/2230
26+
if ($env:PowerShellEdition -eq 'PowerShellCore' -and $PSVersionTable.PSVersion -lt [version]'6.0.2' -and $IsWindows) {
27+
$msiPath = "$env:TEMP\PowerShell-6.0.2-win-x64.msi"
28+
(New-Object Net.WebClient).DownloadFile('https://github.com/PowerShell/PowerShell/releases/download/v6.0.2/PowerShell-6.0.2-win-x64.msi', $msiPath)
29+
Write-Verbose 'Installing pwsh 6.0.2' -Verbose
30+
Start-Process 'msiexec.exe' -Wait -ArgumentList "/i $msiPath /quiet"
31+
Remove-Item $msiPath
32+
$env:Path = "$env:ProgramFiles\PowerShell\6.0.2;$env:Path"
33+
}
2434
2535
build_script:
2636
- ps: |
@@ -48,7 +58,7 @@ test_script:
4858
}
4959
}
5060
- pwsh: |
51-
if ($env:PowerShellEdition -eq 'PowerShellCore' -and $PSVersionTable.PSVersion -ge [version]'6.0.2') {
61+
if ($env:PowerShellEdition -eq 'PowerShellCore') {
5262
$modulePath = $env:PSModulePath.Split([System.IO.Path]::PathSeparator) | Where-Object { Test-Path $_} | Select-Object -First 1
5363
Copy-Item "${env:APPVEYOR_BUILD_FOLDER}\out\PSScriptAnalyzer" "$modulePath\" -Recurse -Force
5464
$testResultsFile = ".\TestResults.xml"

0 commit comments

Comments
 (0)