diff --git a/ElectronNET.CLI/Commands/BuildCommand.cs b/ElectronNET.CLI/Commands/BuildCommand.cs index c240da9..47c64d9 100644 --- a/ElectronNET.CLI/Commands/BuildCommand.cs +++ b/ElectronNET.CLI/Commands/BuildCommand.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Runtime.InteropServices; using System.Threading.Tasks; namespace ElectronNET.CLI.Commands @@ -16,14 +17,28 @@ namespace ElectronNET.CLI.Commands { return Task.Run(() => { - Console.WriteLine("Build Windows Application..."); + Console.WriteLine("Build Electron Application..."); string tempPath = Path.Combine(Directory.GetCurrentDirectory(), "obj", "desktop"); Console.WriteLine("Executing dotnet publish in this directory: " + tempPath); string tempBinPath = Path.Combine(tempPath, "bin"); - ProcessHelper.CmdExecute($"dotnet publish -r win10-x64 --output \"{tempBinPath}\"", Directory.GetCurrentDirectory()); + + bool isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + if (isWindows) + { + Console.WriteLine("Build ASP.NET Core App for Windows..."); + + ProcessHelper.CmdExecute($"dotnet publish -r win10-x64 --output \"{tempBinPath}\"", Directory.GetCurrentDirectory()); + } + else + { + Console.WriteLine("Build ASP.NET Core App for OSX..."); + + // ToDo: Linux... (or maybe via an argument, but this is just for development) + ProcessHelper.CmdExecute($"dotnet publish -r osx-x64 --output \"{tempBinPath}\"", Directory.GetCurrentDirectory()); + } if (Directory.Exists(tempPath) == false) { diff --git a/ElectronNET.CLI/ProcessHelper.cs b/ElectronNET.CLI/ProcessHelper.cs index 3263ba3..775a0c9 100644 --- a/ElectronNET.CLI/ProcessHelper.cs +++ b/ElectronNET.CLI/ProcessHelper.cs @@ -1,5 +1,6 @@ using System; using System.Diagnostics; +using System.Runtime.InteropServices; namespace ElectronNET.CLI { @@ -9,7 +10,19 @@ namespace ElectronNET.CLI { using (Process cmd = new Process()) { - cmd.StartInfo.FileName = "cmd.exe"; + bool isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + + if (isWindows) + { + cmd.StartInfo.FileName = "cmd.exe"; + } + else + { + // ToDo: Linux... + + cmd.StartInfo.FileName = "bash"; + } + cmd.StartInfo.RedirectStandardInput = true; cmd.StartInfo.RedirectStandardOutput = true; cmd.StartInfo.CreateNoWindow = true;