diff --git a/.vsts-ci/windows/templates/windows-packaging.yml b/.vsts-ci/windows/templates/windows-packaging.yml index efef35f24..353d722bb 100644 --- a/.vsts-ci/windows/templates/windows-packaging.yml +++ b/.vsts-ci/windows/templates/windows-packaging.yml @@ -3,6 +3,8 @@ parameters: default: 'Hosted VS2017' - name: jobName default: 'win_packaging' + - name: runtimePrefix + default: 'win7' - name: architecture default: 'x64' - name: channel @@ -40,6 +42,12 @@ jobs: displayName: Capture environment condition: succeededOrFailed() + - pwsh: | + $PSVersionTable + displayName: Capture PowerShell Version Table + condition: succeededOrFailed() + + - template: /tools/releaseBuild/azureDevOps/templates/insert-nuget-config-azfeed.yml - pwsh: | @@ -52,7 +60,7 @@ jobs: - pwsh: | Import-Module .\tools\ci.psm1 New-CodeCoverageAndTestPackage - Invoke-CIFinish -Runtime win7-${{ parameters.architecture }} -channel ${{ parameters.channel }} -Stage Build + Invoke-CIFinish -Runtime ${{ parameters.runtimePrefix }}-${{ parameters.architecture }} -channel ${{ parameters.channel }} -Stage Build displayName: Build workingDirectory: $(repoPath) @@ -65,6 +73,6 @@ jobs: - pwsh: | Import-Module .\tools\ci.psm1 New-CodeCoverageAndTestPackage - Invoke-CIFinish -Runtime win7-${{ parameters.architecture }} -channel ${{ parameters.channel }} -Stage Package + Invoke-CIFinish -Runtime ${{ parameters.runtimePrefix }}-${{ parameters.architecture }} -channel ${{ parameters.channel }} -Stage Package displayName: Package and Test workingDirectory: $(repoPath) diff --git a/.vsts-ci/windows/windows-packaging.yml b/.vsts-ci/windows/windows-packaging.yml index 60bbaedf7..b8aa2c229 100644 --- a/.vsts-ci/windows/windows-packaging.yml +++ b/.vsts-ci/windows/windows-packaging.yml @@ -93,3 +93,13 @@ stages: parameters: channel: preview architecture: x86 + - template: templates/windows-packaging.yml + parameters: + channel: preview + architecture: arm + runtimePrefix: win + - template: templates/windows-packaging.yml + parameters: + channel: preview + architecture: arm64 + runtimePrefix: win diff --git a/tools/ci.psm1 b/tools/ci.psm1 index 1adc4d3eb..ee181f168 100644 --- a/tools/ci.psm1 +++ b/tools/ci.psm1 @@ -463,9 +463,8 @@ function Invoke-CIFinish $previewPrefix = $previewVersion[0] $previewLabel = $previewVersion[1].replace('.','') - if(Test-DailyBuild) - { - $previewLabel= "daily{0}" -f $previewLabel + if (Test-DailyBuild) { + $previewLabel = "daily{0}" -f $previewLabel } $prereleaseIteration = (get-date).Day @@ -477,8 +476,7 @@ function Invoke-CIFinish $filter = Join-Path -Path (Split-Path $options.Output) -ChildPath '*.pdb' Write-Verbose "Removing symbol files from $filter" -Verbose Remove-Item $filter -Force -Recurse - } - else { + } else { $releaseTag = Get-ReleaseTag $releaseTagParts = $releaseTag.split('.') $preReleaseVersion = $releaseTagParts[0]+ ".9.9" @@ -496,106 +494,81 @@ function Invoke-CIFinish $vstsCommandString = "vso[task.setvariable variable=CI_FINISH_RELASETAG]$preReleaseVersion" Write-Verbose -Message "$vstsCommandString" -Verbose Write-Host -Object "##$vstsCommandString" - - $armBuildFolder = "${env:SYSTEM_ARTIFACTSDIRECTORY}/releaseArm32" - - # produce win-arm and win-arm64 packages if it is a daily build - Start-PSBuild -Restore -Runtime win-arm -PSModuleRestore -Configuration 'Release' -ReleaseTag $releaseTag -output $armBuildFolder -PSOptionsPath "${armBuildFolder}-meta/psoptions.json" -Crossgen - $options = Get-PSOptions - # Remove symbol files. - $filter = Join-Path -Path (Split-Path $options.Output) -ChildPath '*.pdb' - Write-Verbose "Removing symbol files from $filter" -Verbose - Remove-Item $filter -Force -Recurse - - $armBuildFolder = "${env:SYSTEM_ARTIFACTSDIRECTORY}/releaseArm64" - Start-PSBuild -Restore -Runtime win-arm64 -PSModuleRestore -Configuration 'Release' -ReleaseTag $releaseTag -output $armBuildFolder -PSOptionsPath "${armBuildFolder}-meta/psoptions.json" -Crossgen - $options = Get-PSOptions - # Remove symbol files. - $filter = Join-Path -Path (Split-Path $options.Output) -ChildPath '*.pdb' - Write-Verbose "Removing symbol files from $filter" -Verbose - Remove-Item $filter -Force -Recurse } - if ($Stage -contains "Package") { - Restore-PSOptions -PSOptionsPath "${buildFolder}-meta/psoptions.json" + Restore-PSOptions -PSOptionsPath "${buildFolder}/psoptions.json" $preReleaseVersion = $env:CI_FINISH_RELASETAG # Build packages $preReleaseVersion = "$previewPrefix-$previewLabel.$prereleaseIteration" - $packages = Start-PSPackage -Type msi, nupkg, zip, zip-pdb -ReleaseTag $preReleaseVersion -SkipReleaseChecks -WindowsRuntime $Runtime + switch -regex ($Runtime){ + default { + $runPackageTest = $true + $packageTypes = 'msi', 'nupkg', 'zip', 'zip-pdb', 'msix' + } + 'win-arm.*' { + $runPackageTest = $false + $packageTypes = 'zip', 'zip-pdb', 'msix' + } + } + $packages = Start-PSPackage -Type $packageTypes -ReleaseTag $preReleaseVersion -SkipReleaseChecks -WindowsRuntime $Runtime foreach ($package in $packages) { - if (Test-Path $package -ErrorAction Ignore) - { + if (Test-Path $package -ErrorAction Ignore) { Write-Log "Package found: $package" - } - else - { + } else { Write-Warning -Message "Package NOT found: $package" } - if($package -is [string]) - { + if ($package -is [string]) { $null = $artifacts.Add($package) - } - elseif($package -is [pscustomobject] -and $package.psobject.Properties['msi']) - { + } elseif ($package -is [pscustomobject] -and $package.psobject.Properties['msi']) { $null = $artifacts.Add($package.msi) $null = $artifacts.Add($package.wixpdb) } } - # the packaging tests find the MSI package using env:PSMsiX64Path - $env:PSMsiX64Path = $artifacts | Where-Object { $_.EndsWith(".msi")} - $architechture = $Runtime.Split('-')[1] - $exePath = New-ExePackage -ProductVersion ($preReleaseVersion -replace '^v') -ProductTargetArchitecture $architechture -MsiLocationPath $env:PSMsiX64Path - Write-Verbose "exe Path: $exePath" -Verbose - $artifacts.Add($exePath) - $env:PSExePath = $exePath - $env:PSMsiChannel = $Channel - $env:PSMsiRuntime = $Runtime + if ($runPackageTest) { + # the packaging tests find the MSI package using env:PSMsiX64Path + $env:PSMsiX64Path = $artifacts | Where-Object { $_.EndsWith(".msi")} + $architechture = $Runtime.Split('-')[1] + $exePath = New-ExePackage -ProductVersion ($preReleaseVersion -replace '^v') -ProductTargetArchitecture $architechture -MsiLocationPath $env:PSMsiX64Path + Write-Verbose "exe Path: $exePath" -Verbose + $artifacts.Add($exePath) + $env:PSExePath = $exePath + $env:PSMsiChannel = $Channel + $env:PSMsiRuntime = $Runtime - # Install the latest Pester and import it - $maximumPesterVersion = '4.99' - Install-Module Pester -Force -SkipPublisherCheck -MaximumVersion $maximumPesterVersion - Import-Module Pester -Force -MaximumVersion $maximumPesterVersion + # Install the latest Pester and import it + $maximumPesterVersion = '4.99' + Install-Module Pester -Force -SkipPublisherCheck -MaximumVersion $maximumPesterVersion + Import-Module Pester -Force -MaximumVersion $maximumPesterVersion - $testResultPath = Join-Path -Path $env:TEMP -ChildPath "win-package-$channel-$runtime.xml" + $testResultPath = Join-Path -Path $env:TEMP -ChildPath "win-package-$channel-$runtime.xml" - # start the packaging tests and get the results - $packagingTestResult = Invoke-Pester -Script (Join-Path $repoRoot '.\test\packaging\windows\') -PassThru -OutputFormat NUnitXml -OutputFile $testResultPath + # start the packaging tests and get the results + $packagingTestResult = Invoke-Pester -Script (Join-Path $repoRoot '.\test\packaging\windows\') -PassThru -OutputFormat NUnitXml -OutputFile $testResultPath - Publish-TestResults -Title "win-package-$channel-$runtime" -Path $testResultPath + Publish-TestResults -Title "win-package-$channel-$runtime" -Path $testResultPath - # fail the CI job if the tests failed, or nothing passed - if(-not $packagingTestResult -is [pscustomobject] -or $packagingTestResult.FailedCount -ne 0 -or $packagingTestResult.PassedCount -eq 0) - { - throw "Packaging tests failed ($($packagingTestResult.FailedCount) failed/$($packagingTestResult.PassedCount) passed)" + # fail the CI job if the tests failed, or nothing passed + if (-not $packagingTestResult -is [pscustomobject] -or $packagingTestResult.FailedCount -ne 0 -or $packagingTestResult.PassedCount -eq 0) { + throw "Packaging tests failed ($($packagingTestResult.FailedCount) failed/$($packagingTestResult.PassedCount) passed)" + } } # only publish assembly nuget packages if it is a daily build and tests passed - if(Test-DailyBuild) - { + if (Test-DailyBuild) { $nugetArtifacts = Get-ChildItem $PSScriptRoot\packaging\nugetOutput -ErrorAction SilentlyContinue -Filter *.nupkg | Select-Object -ExpandProperty FullName - if($nugetArtifacts) - { + if ($nugetArtifacts) { $artifacts.AddRange(@($nugetArtifacts)) } } } - - # produce win-arm and win-arm64 packages if it is a daily build - $armBuildFolder = "${env:SYSTEM_ARTIFACTSDIRECTORY}/releaseArm32" - Restore-PSOptions -PSOptionsPath "${armBuildFolder}-meta/psoptions.json" - $arm32Package = Start-PSPackage -Type zip -WindowsRuntime win-arm -ReleaseTag $releaseTag -SkipReleaseChecks - $artifacts.Add($arm32Package) - - $armBuildFolder = "${env:SYSTEM_ARTIFACTSDIRECTORY}/releaseArm64" - Restore-PSOptions -PSOptionsPath "${armBuildFolder}-meta/psoptions.json" - $arm64Package = Start-PSPackage -Type zip -WindowsRuntime win-arm64 -ReleaseTag $releaseTag -SkipReleaseChecks - $artifacts.Add($arm64Package) - } - finally { + } catch { + Get-Error -InputObject $_ + throw + } finally { $pushedAllArtifacts = $true $artifacts | ForEach-Object { @@ -612,12 +585,6 @@ function Invoke-CIFinish throw "Some artifacts did not exist!" } } - catch - { - Write-Host -Foreground Red $_ - Write-Host -Foreground Red $_.ScriptStackTrace - throw $_ - } } # Bootstrap script for Linux and macOS