I have a custom task which basically executes a powershell script. I have been running this with Powershell 5.1 on the build machine, how do I force execute this into Powershell 7?
This calls Powershell 5.1
"execution": { "Powershell": { "target": "widgetUpload.ps1", "argumentFormat": "", "workingDirectory": "$(currentDirectory)" }
Trying to call Powershell 7 with below, but doesn't work.
"execution": { "pwsh": { "target": "widgetUpload.ps1", "argumentFormat": "", "workingDirectory": "$(currentDirectory)" }
We are on TFS 2018.
There is no such option. There is no PowerShell Core execution handler.
The only thing you can do is add a wrapper script that calls
pwshfrom the Windows PowerShell. That's also how thePowerShell@2tasks does it:https://github.com/microsoft/azure-pipelines-tasks/blob/a1fb3829bbfe59c6fa0ace05e0f81a52da8fc8db/Tasks/PowerShellV2/powershell.ps1#L149-L180
You should upgrade to the
PowerShell3handler though, but that will still rely on PowerShell 5.1.