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
pwshas a shell, which will use thepowershellshell writer, but instead of invokingpowershellinvokepwsh. Something similar to what we do inbashandshjust no fallback. There is WIP merge request !1855 (closed). The reason for having a new shell the user has to configured instead of just usingpowershellis because if we makepowershelljust 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. -
pwshaccepts both/and\in the path for Unix based systems, butgitdoesn'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 aJoinfunction to extend the which will set the correct slash depending on script type and call it instead ofpath.Join. Another way to do this is don't covert to backslash ifpwshis chosen. - We use
$env:computernameto print out the first line of the jobRunning on ...,$env:computernamedoesn't seem available on Unix pwsh, so have some kind of fallback environment such ashostname.- Pedro: We can probably replace with
[Environment]::MachineName.
- Pedro: We can probably replace with
- When
pwshis choosen, set theErrorActionPreferencetoStopto prevent problems like #3194 (closed) for PowerShell 7 - Add Powershell Core to CI Docker image, so that Powershell tests can be run against
pwshshell as well
Links to related issues and merge requests / references
Edited by Pedro Pombeiro