From 5c14e585cfc6aac41abe8b741b8b6ec68eedd668 Mon Sep 17 00:00:00 2001 From: Robert Muehsig Date: Wed, 15 Nov 2017 23:42:15 +0100 Subject: [PATCH] fix https://github.com/ElectronNET/Electron.NET/issues/52 --- ElectronNET.CLI/Commands/BuildCommand.cs | 8 +++++++- .../Commands/StartElectronCommand.cs | 8 +++++++- ElectronNET.CLI/ProcessHelper.cs | 17 +++++++++++++++-- buildAll.cmd | 10 +++++----- 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/ElectronNET.CLI/Commands/BuildCommand.cs b/ElectronNET.CLI/Commands/BuildCommand.cs index 2db6803..ff5fea4 100644 --- a/ElectronNET.CLI/Commands/BuildCommand.cs +++ b/ElectronNET.CLI/Commands/BuildCommand.cs @@ -49,7 +49,13 @@ namespace ElectronNET.CLI.Commands Console.WriteLine($"Build ASP.NET Core App for {platformInfo.NetCorePublishRid}..."); - ProcessHelper.CmdExecute($"dotnet publish -r {platformInfo.NetCorePublishRid} --output \"{tempBinPath}\"", Directory.GetCurrentDirectory()); + var resultCode = ProcessHelper.CmdExecute($"dotnet publish -r {platformInfo.NetCorePublishRid} --output \"{tempBinPath}\"", Directory.GetCurrentDirectory()); + + if (resultCode != 0) + { + Console.WriteLine("Error occured during dotnet publish."); + return false; + } DeployEmbeddedElectronFiles.Do(tempPath); diff --git a/ElectronNET.CLI/Commands/StartElectronCommand.cs b/ElectronNET.CLI/Commands/StartElectronCommand.cs index 147ceac..86585fb 100644 --- a/ElectronNET.CLI/Commands/StartElectronCommand.cs +++ b/ElectronNET.CLI/Commands/StartElectronCommand.cs @@ -51,7 +51,13 @@ namespace ElectronNET.CLI.Commands var platformInfo = GetTargetPlatformInformation.Do(string.Empty); string tempBinPath = Path.Combine(tempPath, "bin"); - ProcessHelper.CmdExecute($"dotnet publish -r {platformInfo.NetCorePublishRid} --output \"{tempBinPath}\"", aspCoreProjectPath); + var resultCode = ProcessHelper.CmdExecute($"dotnet publish -r {platformInfo.NetCorePublishRid} --output \"{tempBinPath}\"", aspCoreProjectPath); + + if (resultCode != 0) + { + Console.WriteLine("Error occured during dotnet publish."); + return false; + } DeployEmbeddedElectronFiles.Do(tempPath); diff --git a/ElectronNET.CLI/ProcessHelper.cs b/ElectronNET.CLI/ProcessHelper.cs index e0afe87..e348e29 100644 --- a/ElectronNET.CLI/ProcessHelper.cs +++ b/ElectronNET.CLI/ProcessHelper.cs @@ -6,7 +6,7 @@ namespace ElectronNET.CLI { public class ProcessHelper { - public static void CmdExecute(string command, string workingDirectoryPath, bool output = true, bool waitForExit = true) + public static int CmdExecute(string command, string workingDirectoryPath, bool output = true, bool waitForExit = true) { using (Process cmd = new Process()) { @@ -28,10 +28,21 @@ namespace ElectronNET.CLI cmd.StartInfo.CreateNoWindow = true; cmd.StartInfo.UseShellExecute = false; cmd.StartInfo.WorkingDirectory = workingDirectoryPath; + + int returnCode = 0; + if (output) { cmd.OutputDataReceived += (s, e) => Console.WriteLine(e.Data); - cmd.ErrorDataReceived += (s, e) => Console.WriteLine(e.Data); + cmd.ErrorDataReceived += (s, e) => + { + // we can't just use cmd.ExitCode, because + // we delegate it to cmd.exe, which runs fine + // but we can catch any error here and return + // 1 if something fails + returnCode = 1; + Console.WriteLine(e.Data); + }; } cmd.Start(); @@ -46,6 +57,8 @@ namespace ElectronNET.CLI { cmd.WaitForExit(); } + + return returnCode; } } } diff --git a/buildAll.cmd b/buildAll.cmd index f042297..a1dd47f 100755 --- a/buildAll.cmd +++ b/buildAll.cmd @@ -22,9 +22,9 @@ dotnet "../ElectronNET.CLI/bin/Debug/netcoreapp2.0/dotnet-electronize.dll" build echo "-- linux (dev-build)" dotnet "../ElectronNET.CLI/bin/Debug/netcoreapp2.0/dotnet-electronize.dll" build linux -REM Be aware, that for non-electronnet-dev environments the correct -REM invoke command would be dotnet electronize ... +:: Be aware, that for non-electronnet-dev environments the correct +:: invoke command would be dotnet electronize ... -REM Not supported on Windows Systems, because of SymLinks... -REM echo "-- osx" -REM dotnet electronize build osx +:: Not supported on Windows Systems, because of SymLinks... +:: echo "-- osx" +:: dotnet electronize build osx