Default to pwsh with powershell as a fallback (#142)

* Default to pwsh with powershell as a fallback

* Update releaseNote.md

* clean up code
This commit is contained in:
Thomas Boop
2019-10-23 11:24:02 -04:00
committed by GitHub
parent 7b158fff05
commit f1c58c33b6
2 changed files with 17 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
## Features ## Features
- Set Default shell to powershell for windows runners (#135) - Set Default shell to powershell for windows runners (#135)
- Use Powershell as fallback if Powershell Core is not available for default shell on windows (#142)
## Bugs ## Bugs
- Removed unintended additional fields on error and warning commands (#137) - Removed unintended additional fields on error and warning commands (#137)

View File

@@ -60,10 +60,16 @@ namespace GitHub.Runner.Worker.Handlers
if (string.IsNullOrEmpty(shell)) if (string.IsNullOrEmpty(shell))
{ {
#if OS_WINDOWS #if OS_WINDOWS
shellCommand = "powershell"; shellCommand = "pwsh";
if(validateShellOnHost) if(validateShellOnHost)
{ {
shellCommandPath = WhichUtil.Which(shellCommand, true, Trace); shellCommandPath = WhichUtil.Which(shellCommand, require: false, Trace);
if (string.IsNullOrEmpty(shellCommandPath))
{
shellCommand = "powershell";
Trace.Info($"Defaulting to {shellCommand}");
shellCommandPath = WhichUtil.Which(shellCommand, require: true, Trace);
}
} }
#else #else
shellCommand = "sh"; shellCommand = "sh";
@@ -143,8 +149,14 @@ namespace GitHub.Runner.Worker.Handlers
if (string.IsNullOrEmpty(shell)) if (string.IsNullOrEmpty(shell))
{ {
#if OS_WINDOWS #if OS_WINDOWS
shellCommand = "pwsh";
commandPath = WhichUtil.Which(shellCommand, require: false, Trace);
if (string.IsNullOrEmpty(commandPath))
{
shellCommand = "powershell"; shellCommand = "powershell";
commandPath = WhichUtil.Which(shellCommand, true, Trace); Trace.Info($"Defaulting to {shellCommand}");
commandPath = WhichUtil.Which(shellCommand, require: true, Trace);
}
ArgUtil.NotNullOrEmpty(commandPath, "Default Shell"); ArgUtil.NotNullOrEmpty(commandPath, "Default Shell");
#else #else
shellCommand = "sh"; shellCommand = "sh";