diff --git a/scripts/runhelpers.cake b/scripts/runhelpers.cake
index 4b9d4d52..69c262b0 100644
--- a/scripts/runhelpers.cake
+++ b/scripts/runhelpers.cake
@@ -31,25 +31,20 @@ public class RunOptions
///
public struct ExitStatus
{
- private int _code;
+ private string _cmd;
+ private string _args;
+ private int _exitCode;
private bool _timeOut;
///
- /// Default constructor when the execution finished.
- ///
- /// The exit code
- public ExitStatus(int code)
- {
- this._code = code;
- this._timeOut = false;
- }
- ///
/// Default constructor when the execution potentially timed out.
///
- /// The exit code
+ /// The process this status is for
/// True if the execution timed out
- public ExitStatus(int code, bool timeOut)
+ public ExitStatus(string cmd, string args, int exitCode, bool timeOut = false)
{
- this._code = code;
+ this._cmd = cmd;
+ this._args = args;
+ this._exitCode = exitCode;
this._timeOut = timeOut;
}
///
@@ -63,7 +58,7 @@ public struct ExitStatus
/// The exit code
public static implicit operator int(ExitStatus exitStatus)
{
- return exitStatus._code;
+ return exitStatus._exitCode;
}
///
/// Trigger Exception for non-zero exit code.
@@ -72,9 +67,9 @@ public struct ExitStatus
/// The exit status for further queries
public ExitStatus ExceptionOnError(string errorMessage)
{
- if (this._code != 0)
+ if (this._exitCode != 0)
{
- throw new Exception(errorMessage);
+ throw new Exception(errorMessage + $"\nCommand: {this._cmd} {this._args}");
}
return this;
}
@@ -150,19 +145,19 @@ ExitStatus Run(string exec, string args, RunOptions runOptions)
if (runOptions.TimeOut == 0)
{
process.WaitForExit();
- return new ExitStatus(process.ExitCode);
+ return new ExitStatus(exec, args, process.ExitCode);
}
else
{
bool finished = process.WaitForExit(runOptions.TimeOut);
if (finished)
{
- return new ExitStatus(process.ExitCode);
+ return new ExitStatus(exec, args, process.ExitCode);
}
else
{
KillProcessTree(process);
- return new ExitStatus(0, true);
+ return new ExitStatus(exec, args, 0, true);
}
}
}
@@ -177,25 +172,12 @@ ExitStatus Run(string exec, string args, RunOptions runOptions)
ExitStatus RunRestore(string exec, string args, string workingDirectory)
{
Information("Restoring packages....");
- var p = StartAndReturnProcess(exec,
- new ProcessSettings
- {
- Arguments = args,
- RedirectStandardOutput = true,
- WorkingDirectory = workingDirectory
- });
- p.WaitForExit();
- var exitCode = p.GetExitCode();
+ var exitStatus = Run(exec, args, new RunOptions {
+ WorkingDirectory = workingDirectory
+ }).ExceptionOnError($"Error restoring packages.");
- if (exitCode == 0)
- {
- Information("Package restore successful!");
- }
- else
- {
- Error(string.Join("\n", p.GetStandardOutput()));
- }
- return new ExitStatus(exitCode);
+ Information("Package restore successful!");
+ return exitStatus;
}
///