Skip to content

Enable PowerShell Core support in Shell Executor

Description

Enable PowerShell 6 Core support in the Shell Exeuctor

Proposal

In #3291 (closed) we evaluated the feasibility of including Powershell Core 6 to the Runner executors. There is now an open !2199 (merged) that will enable this capability.

  • Allow user to specify pwsh as a shell, which will use the powershell shell writer, but instead of invoking powershell invoke pwsh. Something similar to what we do in bash and sh just no fallback. There is WIP merge request !1855 (closed). The reason for having a new shell the user has to configured instead of just using powershell is because if we make powershell just use PowerShell 6/7 out of the box if its available we are going to end up breaking existing scripts for users that expect to use PowerShell 5, like this users need to be aware of the change they make.
  • pwsh accepts both / and \ in the path for Unix based systems, but git doesn't accept them. When we use the powershell script generator we use \ since that is the acceptable version for Windows. This leads to problems like this fails CI job. In !1855 (diffs) we extend the Extend the ShellWriter interface and implement a Join function to extend the which will set the correct slash depending on script type and call it instead of path.Join. Another way to do this is don't covert to backslash if pwsh is chosen.
  • We use $env:computername to print out the first line of the job Running on ..., $env:computername doesn't seem available on Unix pwsh, so have some kind of fallback environment such as hostname.
    • Pedro: We can probably replace with [Environment]::MachineName.
  • When pwsh is choosen, set the ErrorActionPreference to Stop to prevent problems like #3194 (closed) for PowerShell 7
  • Add Powershell Core to CI Docker image, so that Powershell tests can be run against pwsh shell as well

Links to related issues and merge requests / references

!2199 (merged)

#3291 (closed)

Edited by Pedro Pombeiro