From 81786a87348f4b9273030bd8b56594188ed19845 Mon Sep 17 00:00:00 2001 From: Alper Ebicoglu Date: Thu, 28 Jan 2021 19:49:03 +0300 Subject: [PATCH] fix shell command for Alpine Linux Distribution. closes volosoft/volo#5153 --- .../Volo/Abp/Cli/Utils/CmdHelper.cs | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Utils/CmdHelper.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Utils/CmdHelper.cs index 819022e672..07b470225a 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Utils/CmdHelper.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Utils/CmdHelper.cs @@ -1,4 +1,5 @@ using System.Diagnostics; +using System.IO; using System.Runtime.InteropServices; namespace Volo.Abp.Cli.Utils @@ -103,14 +104,28 @@ namespace Volo.Abp.Cli.Utils public static string GetFileName() { - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + //Windows + return "cmd.exe"; + } + + //Linux or OSX + if (File.Exists("/bin/bash")) { - //TODO: Test this. it should work for both operation systems. return "/bin/bash"; } - //Windows default. - return "cmd.exe"; + if (File.Exists("/bin/sh")) + { + return "/bin/sh"; //some Linux distributions like Alpine doesn't have bash + } + + throw new AbpException($"Cannot determine shell command for this OS! " + + $"Running on OS: {System.Runtime.InteropServices.RuntimeInformation.OSDescription} | " + + $"OS Architecture: {System.Runtime.InteropServices.RuntimeInformation.OSArchitecture} | " + + $"Framework: {System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription} | " + + $"Process Architecture{System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture}"); } } }