From 5658a74fef38a23338b5958e518589c19f2c6d9d Mon Sep 17 00:00:00 2001 From: Rob Holt Date: Wed, 19 Feb 2020 16:17:26 -0800 Subject: [PATCH 1/2] Add pwsh install step to build --- .vsts-ci/templates/release-general.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.vsts-ci/templates/release-general.yml b/.vsts-ci/templates/release-general.yml index cc4b802a24..916a14ee1a 100644 --- a/.vsts-ci/templates/release-general.yml +++ b/.vsts-ci/templates/release-general.yml @@ -1,4 +1,13 @@ steps: +- powershell: | + $powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell' + Invoke-WebRequest -Uri https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.ps1 -outfile ./install-powershell.ps1 + ./install-powershell.ps1 -Destination $powerShellPath + $vstsCommandString = "vso[task.setvariable variable=PATH]$powerShellPath;$env:PATH" + Write-Host "sending " + $vstsCommandString + Write-Host "##$vstsCommandString" + displayName: Install PowerShell Core + - pwsh: Write-Host "##vso[build.updatebuildnumber]$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhmmss"))" displayName: Set Build Name for Non-PR condition: ne(variables['Build.Reason'], 'PullRequest') From c24f9a79b842265a20d1bc72cc966c35163d9ed3 Mon Sep 17 00:00:00 2001 From: Rob Holt Date: Wed, 19 Feb 2020 16:26:13 -0800 Subject: [PATCH 2/2] Skip pwsh installation when it already exists --- .vsts-ci/templates/release-general.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.vsts-ci/templates/release-general.yml b/.vsts-ci/templates/release-general.yml index 916a14ee1a..ebf8c3b53f 100644 --- a/.vsts-ci/templates/release-general.yml +++ b/.vsts-ci/templates/release-general.yml @@ -1,5 +1,11 @@ steps: - powershell: | + Write-Host "Installing pwsh..." + if (Get-Command pwsh -ErrorAction Ignore) + { + Write-Host "pwsh already installed, skipping" + return + } $powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell' Invoke-WebRequest -Uri https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.ps1 -outfile ./install-powershell.ps1 ./install-powershell.ps1 -Destination $powerShellPath