Skip to content

Commit ddc2bc2

Browse files
Merge pull request #35 from bdukes/failure-exit-code
Emit non-zero exit code if any installs failed
2 parents 3f33ae5 + 12a0601 commit ddc2bc2

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

DeployClient/Program.cs

+12-1
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ static async Task Main(string[] args)
228228
// Finished install.
229229
WriteLine(string.Format("Finished installation in {0} ms.", (DateTime.Now - installStartTime).TotalMilliseconds));
230230
ReadLine();
231+
232+
int succeeded = ParseResults(results).succeeded;
233+
bool allSucceeded = succeeded == results.Count;
234+
ExitCode exitCode = allSucceeded ? ExitCode.Success : ExitCode.InstallFailure;
235+
Environment.Exit((int)exitCode);
231236
}
232237
catch (Exception ex)
233238
{
@@ -268,6 +273,12 @@ private static void GetSettings(string[] args)
268273
}
269274

270275
private static string BuildUpdateString(SortedList<string, dynamic> results)
276+
{
277+
var (attempted, succeeded, _) = ParseResults(results);
278+
return string.Format("\t{0}/{1} module archives processed, {2}/{0} succeeded.", attempted, results.Count, succeeded);
279+
}
280+
281+
private static (int attempted, int succeeded, int failed) ParseResults(SortedList<string, dynamic> results)
271282
{
272283
// Get counts.
273284
int attempted = 0;
@@ -293,7 +304,7 @@ private static string BuildUpdateString(SortedList<string, dynamic> results)
293304
}
294305
}
295306

296-
return string.Format("\t{0}/{1} module archives processed, {2}/{0} succeeded.", attempted, results.Count, succeeded);
307+
return (attempted, succeeded, failed);
297308
}
298309

299310
private static void WriteException(Exception ex, int maxDepth = 10, int depth = 0)

0 commit comments

Comments
 (0)