diff --git a/eng/common/testproxy/scripts/tag-merge/README.md b/eng/common/testproxy/scripts/tag-merge/README.md index aa524282e8..d72dd4dbef 100644 --- a/eng/common/testproxy/scripts/tag-merge/README.md +++ b/eng/common/testproxy/scripts/tag-merge/README.md @@ -11,6 +11,7 @@ This script merely allows the abstraction of some of this "combination" work. ### PreReqs +- Must have []`pshell 6+`](https://learn.microsoft.com/powershell/scripting/install/installing-powershell-on-windows) - Must have `git` available on your PATH - Must have the `test-proxy` available on your PATH - `test-proxy` is honored when the proxy is installed as a `dotnet tool` diff --git a/eng/common/testproxy/scripts/tag-merge/merge-proxy-tags.ps1 b/eng/common/testproxy/scripts/tag-merge/merge-proxy-tags.ps1 index 866a5f787d..18e57acc58 100644 --- a/eng/common/testproxy/scripts/tag-merge/merge-proxy-tags.ps1 +++ b/eng/common/testproxy/scripts/tag-merge/merge-proxy-tags.ps1 @@ -1,3 +1,6 @@ +#Requires -Version 6.0 +#Requires -PSEdition Core + <# .SYNOPSIS Merge multiple asset tagss worth of content into a single asset tag. @@ -66,9 +69,6 @@ function Git-Command($CommandString, $WorkingDirectory, $HardExit=$true) { } function Resolve-Proxy { - # this script requires the presence of git - Test-Exe-In-Path -ExeToLookFor "git" | Out-Null - $testProxyExe = "test-proxy" # this script requires the presence of the test-proxy on the PATH $proxyToolPresent = Test-Exe-In-Path -ExeToLookFor "test-proxy" -ExitOnError $false @@ -184,7 +184,13 @@ function Start-Message($AssetsJson, $TargetTags, $AssetsRepoLocation, $MountDire function Finish-Message($AssetsJson, $TargetTags, $AssetsRepoLocation, $MountDirectory) { $len = $TargetTags.Length - Write-Host "`nSuccessfully combined $len tags. Invoke `"test-proxy push " -NoNewLine + if ($TargetTags.GetType().Name -eq "String") { + $len = 1 + } + + $suffix = if ($len -gt 1) { "s" } else { "" } + + Write-Host "`nSuccessfully combined $len tag$suffix. Invoke `"test-proxy push " -NoNewLine Write-Host $AssetsJson -ForegroundColor Green -NoNewLine Write-Host "`" to push the results as a new tag." } @@ -270,12 +276,22 @@ function Combine-Tags($RemainingTags, $AssetsRepoLocation, $MountDirectory){ # if we have successfully gotten to the end without any non-zero exit codes...delete the mergeprogress file, we're g2g Cleanup-Incomplete-Progress $MountDirectory - return $pushedTags + return @($pushedTags) } $ErrorActionPreference = "Stop" -# resolve the proxy location so that we can invoke it easily +# this script requires the presence of git +Test-Exe-In-Path -ExeToLookFor "git" | Out-Null + +# this script expects at least powershell 6 (core) + +if ($PSVersionTable["PSVersion"].Major -lt 6) { + Write-Error "This script requires a version of powershell newer than 6. See http://aka.ms/powershell for resolution." + exit 1 +} + +# resolve the proxy location so that we can invoke it easily, if not present we exit here. $proxyExe = Resolve-Proxy $AssetsJson = Resolve-Path $AssetsJson