Skip to content

Commit 5c14e58

Browse files
committed
fix #52
1 parent d1b42fa commit 5c14e58

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed

ElectronNET.CLI/Commands/BuildCommand.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,13 @@ public Task<bool> ExecuteAsync()
4949

5050
Console.WriteLine($"Build ASP.NET Core App for {platformInfo.NetCorePublishRid}...");
5151

52-
ProcessHelper.CmdExecute($"dotnet publish -r {platformInfo.NetCorePublishRid} --output \"{tempBinPath}\"", Directory.GetCurrentDirectory());
52+
var resultCode = ProcessHelper.CmdExecute($"dotnet publish -r {platformInfo.NetCorePublishRid} --output \"{tempBinPath}\"", Directory.GetCurrentDirectory());
53+
54+
if (resultCode != 0)
55+
{
56+
Console.WriteLine("Error occured during dotnet publish.");
57+
return false;
58+
}
5359

5460
DeployEmbeddedElectronFiles.Do(tempPath);
5561

ElectronNET.CLI/Commands/StartElectronCommand.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ public Task<bool> ExecuteAsync()
5151
var platformInfo = GetTargetPlatformInformation.Do(string.Empty);
5252

5353
string tempBinPath = Path.Combine(tempPath, "bin");
54-
ProcessHelper.CmdExecute($"dotnet publish -r {platformInfo.NetCorePublishRid} --output \"{tempBinPath}\"", aspCoreProjectPath);
54+
var resultCode = ProcessHelper.CmdExecute($"dotnet publish -r {platformInfo.NetCorePublishRid} --output \"{tempBinPath}\"", aspCoreProjectPath);
55+
56+
if (resultCode != 0)
57+
{
58+
Console.WriteLine("Error occured during dotnet publish.");
59+
return false;
60+
}
5561

5662
DeployEmbeddedElectronFiles.Do(tempPath);
5763

ElectronNET.CLI/ProcessHelper.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace ElectronNET.CLI
66
{
77
public class ProcessHelper
88
{
9-
public static void CmdExecute(string command, string workingDirectoryPath, bool output = true, bool waitForExit = true)
9+
public static int CmdExecute(string command, string workingDirectoryPath, bool output = true, bool waitForExit = true)
1010
{
1111
using (Process cmd = new Process())
1212
{
@@ -28,10 +28,21 @@ public static void CmdExecute(string command, string workingDirectoryPath, bool
2828
cmd.StartInfo.CreateNoWindow = true;
2929
cmd.StartInfo.UseShellExecute = false;
3030
cmd.StartInfo.WorkingDirectory = workingDirectoryPath;
31+
32+
int returnCode = 0;
33+
3134
if (output)
3235
{
3336
cmd.OutputDataReceived += (s, e) => Console.WriteLine(e.Data);
34-
cmd.ErrorDataReceived += (s, e) => Console.WriteLine(e.Data);
37+
cmd.ErrorDataReceived += (s, e) =>
38+
{
39+
// we can't just use cmd.ExitCode, because
40+
// we delegate it to cmd.exe, which runs fine
41+
// but we can catch any error here and return
42+
// 1 if something fails
43+
returnCode = 1;
44+
Console.WriteLine(e.Data);
45+
};
3546
}
3647

3748
cmd.Start();
@@ -46,6 +57,8 @@ public static void CmdExecute(string command, string workingDirectoryPath, bool
4657
{
4758
cmd.WaitForExit();
4859
}
60+
61+
return returnCode;
4962
}
5063
}
5164
}

buildAll.cmd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ dotnet "../ElectronNET.CLI/bin/Debug/netcoreapp2.0/dotnet-electronize.dll" build
2222
echo "-- linux (dev-build)"
2323
dotnet "../ElectronNET.CLI/bin/Debug/netcoreapp2.0/dotnet-electronize.dll" build linux
2424

25-
REM Be aware, that for non-electronnet-dev environments the correct
26-
REM invoke command would be dotnet electronize ...
25+
:: Be aware, that for non-electronnet-dev environments the correct
26+
:: invoke command would be dotnet electronize ...
2727

28-
REM Not supported on Windows Systems, because of SymLinks...
29-
REM echo "-- osx"
30-
REM dotnet electronize build osx
28+
:: Not supported on Windows Systems, because of SymLinks...
29+
:: echo "-- osx"
30+
:: dotnet electronize build osx

0 commit comments

Comments
 (0)