diff --git a/appveyor.yml b/appveyor.yml index 850d5b413..986a0e22d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,17 +1,16 @@ environment: + PSVersion: 5 + BuildConfiguration: Release matrix: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 PowerShellEdition: PowerShellCore - BuildConfiguration: Release - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 PowerShellEdition: WindowsPowerShell - BuildConfiguration: Release - APPVEYOR_BUILD_WORKER_IMAGE: WMF 4 PowerShellEdition: WindowsPowerShell - BuildConfiguration: PSv4Release + PSVersion: 4 - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu PowerShellEdition: PowerShellCore - BuildConfiguration: Release # cache Nuget packages and dotnet CLI cache cache: @@ -33,29 +32,29 @@ install: build_script: - ps: | - if ($env:PowerShellEdition -eq 'WindowsPowerShell') { - if ($env:BuildConfiguration -eq 'PSv4Release') { - # On WMF$: Also build for v3 to check it builds at least since we do not have a WMF3 image - Invoke-AppveyorBuild -CheckoutPath $env:APPVEYOR_BUILD_FOLDER -BuildConfiguration PSv3Release -BuildType 'FullCLR' - } - Invoke-AppveyorBuild -CheckoutPath $env:APPVEYOR_BUILD_FOLDER -BuildConfiguration $env:BuildConfiguration -BuildType 'FullCLR' - } + Set-Location $env:APPVEYOR_BUILD_FOLDER + ./build.ps1 -Documentation + if ( $env:PSVersion -eq "4" ) { # On WMF4: Also build for v3 to check it builds at least since we do not have a WMF3 image + ./build.ps1 -Configuration "$env:BuildConfiguration" -PSVersion 3 -Framework full + } + ./build.ps1 -Configuration "$env:BuildConfiguration" -PSVersion "$env:PSVersion" -Framework full - pwsh: | - if ($env:PowerShellEdition -eq 'PowerShellCore') { - Import-Module .\tools\appveyor.psm1 # Appveyor does not persist pwsh sessions like it does for ps - Invoke-AppveyorBuild -CheckoutPath $env:APPVEYOR_BUILD_FOLDER -BuildConfiguration $env:BuildConfiguration -BuildType 'NetStandard' - } + if ($env:PowerShellEdition -eq 'PowerShellCore') { + Set-Location $env:APPVEYOR_BUILD_FOLDER + ./build.ps1 -Documentation + ./build.ps1 -Configuration "$env:BuildConfiguration" -PSVersion 5 -Framework core + } test_script: - ps: | - if ($env:PowerShellEdition -eq 'WindowsPowerShell') { - Invoke-AppveyorTest -CheckoutPath $env:APPVEYOR_BUILD_FOLDER - } + if ($env:PowerShellEdition -eq 'WindowsPowerShell') { + Invoke-AppveyorTest -CheckoutPath $env:APPVEYOR_BUILD_FOLDER + } - pwsh: | - if ($env:PowerShellEdition -eq 'PowerShellCore') { - Import-Module .\tools\appveyor.psm1 # Appveyor does not persist pwsh sessions like it does for ps - Invoke-AppveyorTest -CheckoutPath $env:APPVEYOR_BUILD_FOLDER - } + if ($env:PowerShellEdition -eq 'PowerShellCore') { + Import-Module .\tools\appveyor.psm1 # Appveyor does not persist pwsh sessions like it does for ps + Invoke-AppveyorTest -CheckoutPath $env:APPVEYOR_BUILD_FOLDER + } # Upload the project along with test results as a zip archive on_finish: diff --git a/build.psm1 b/build.psm1 index 547350ffc..61b63bee5 100644 --- a/build.psm1 +++ b/build.psm1 @@ -87,7 +87,6 @@ function Remove-Build } } - # Build documentation using platyPS function Build-Documentation { @@ -95,8 +94,9 @@ function Build-Documentation $markdownDocsPath = Join-Path $docsPath markdown $outputDocsPath = Join-Path $destinationDir en-US $requiredVersionOfplatyPS = 0.9 - $modInfo = new-object Microsoft.PowerShell.Commands.ModuleSpecification -ArgumentList @{ ModuleName = "platyps"; ModuleVersion = $requiredVersionOfplatyPS} - if ( $null -eq (Get-Module -ListAvailable -FullyQualifiedName $modInfo)) + #$modInfo = new-object Microsoft.PowerShell.Commands.ModuleSpecification -ArgumentList @{ ModuleName = "platyps"; ModuleVersion = $requiredVersionOfplatyPS} + #if ( $null -eq (Get-Module -ListAvailable -FullyQualifiedName $modInfo)) + if ( $null -eq (Get-Module -ListAvailable platyPS)) { throw "Cannot find required minimum version $requiredVersionOfplatyPS of platyPS. Install via 'Install-Module platyPS'" } diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 130488f8d..a65c95b19 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -5,31 +5,36 @@ $ErrorActionPreference = 'Stop' # Implements the AppVeyor 'install' step and installs the required versions of Pester, platyPS and the .Net Core SDK if needed. function Invoke-AppVeyorInstall { - $requiredPesterVersion = '4.3.1' + $requiredPesterVersion = '4.4.1' $pester = Get-Module Pester -ListAvailable | Where-Object { $_.Version -eq $requiredPesterVersion } if ($null -eq $pester) { if ($null -eq (Get-Module -ListAvailable PowershellGet)) { # WMF 4 image build + Write-Verbose -Verbose "Installing Pester via nuget" nuget install Pester -Version $requiredPesterVersion -source https://www.powershellgallery.com/api/v2 -outputDirectory "$env:ProgramFiles\WindowsPowerShell\Modules\." -ExcludeVersion } else { # Visual Studio 2017 build (has already Pester v3, therefore a different installation mechanism is needed to make it also use the new version 4) + Write-Verbose -Verbose "Installing Pester via Install-Module" Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser } } if ($null -eq (Get-Module -ListAvailable PowershellGet)) { # WMF 4 image build + Write-Verbose -Verbose "Installing platyPS via nuget" nuget install platyPS -Version 0.9.0 -source https://www.powershellgallery.com/api/v2 -outputDirectory "$Env:ProgramFiles\WindowsPowerShell\Modules\." -ExcludeVersion } else { + Write-Verbose -Verbose "Installing platyPS via Install-Module" Install-Module -Name platyPS -Force -Scope CurrentUser -RequiredVersion '0.9.0' } # the legacy WMF4 image only has the old preview SDKs of dotnet $globalDotJson = Get-Content (Join-Path $PSScriptRoot '..\global.json') -Raw | ConvertFrom-Json $dotNetCoreSDKVersion = $globalDotJson.sdk.version - if (-not ((dotnet --version).StartsWith($dotNetCoreSDKVersion))) { + # don't try to run this script on linux - we have to do the negative check because IsLinux will be defined in core, but not windows + if (-not ((dotnet --version).StartsWith($dotNetCoreSDKVersion)) -and ! $IsLinux ) { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 # https://github.com/dotnet/announcements/issues/77 Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile dotnet-install.ps1 .\dotnet-install.ps1 -Version $dotNetCoreSDKVersion @@ -37,37 +42,6 @@ function Invoke-AppVeyorInstall { } } -# Implements the AppVeyor 'build_script' step -function Invoke-AppVeyorBuild { - Param( - [Parameter(Mandatory)] - [ValidateSet('FullCLR', 'NetStandard')] - $BuildType, - - [Parameter(Mandatory)] - [ValidateSet('Release', 'PSv3Release', 'PSv4Release')] - $BuildConfiguration, - - [Parameter(Mandatory)] - [ValidateScript( {Test-Path $_})] - $CheckoutPath - ) - - $PSVersionTable - Write-Verbose "Pester version: $((Get-Command Invoke-Pester).Version)" -Verbose - Write-Verbose ".NET SDK version: $(dotnet --version)" -Verbose - Push-Location $CheckoutPath - [Environment]::SetEnvironmentVariable("DOTNET_SKIP_FIRST_TIME_EXPERIENCE", 1) # avoid unneccessary initialization in CI - if ($BuildType -eq 'FullCLR') { - .\buildCoreClr.ps1 -Framework net451 -Configuration $BuildConfiguration -Build - } - elseif ($BuildType -eq 'NetStandard') { - .\buildCoreClr.ps1 -Framework netstandard2.0 -Configuration Release -Build - } - .\build.ps1 -BuildDocs - Pop-Location -} - # Implements AppVeyor 'test_script' step function Invoke-AppveyorTest { Param( @@ -97,4 +71,4 @@ function Invoke-AppveyorFinish { # You can add other artifacts here (Get-ChildItem $zipFile) ) | ForEach-Object { Push-AppveyorArtifact $_.FullName } -} \ No newline at end of file +}