diff --git a/aeqw89.tools.Publish/Exceptions.Designer.cs b/aeqw89.tools.Publish/Exceptions.Designer.cs
index ce608e7..89a52e9 100644
--- a/aeqw89.tools.Publish/Exceptions.Designer.cs
+++ b/aeqw89.tools.Publish/Exceptions.Designer.cs
@@ -96,7 +96,7 @@ namespace aeqw89.tools.Publish {
}
///
- /// Looks up a localized string similar to Failed to pack; ensure that 'dotnet build' succeeds before running this program..
+ /// Looks up a localized string similar to Failed to pack with exit code '{0}'; ensure that 'dotnet build' succeeds before running this program..
///
internal static string dotnet_pack_failure {
get {
diff --git a/aeqw89.tools.Publish/Exceptions.resx b/aeqw89.tools.Publish/Exceptions.resx
index 640185f..32544d0 100644
--- a/aeqw89.tools.Publish/Exceptions.resx
+++ b/aeqw89.tools.Publish/Exceptions.resx
@@ -58,7 +58,7 @@
The project file '{0}' is irreparable becuase it is missing a '{1}' property, and the value cannot be guessed.
- Failed to pack; ensure that 'dotnet build' succeeds before running this program.
+ Failed to pack with exit code '{0}'; ensure that 'dotnet build' succeeds before running this program.
Could not delete temporary directory '{0}' due to error '{1}'
diff --git a/aeqw89.tools.Publish/Program.cs b/aeqw89.tools.Publish/Program.cs
index 7e00f73..850cd02 100644
--- a/aeqw89.tools.Publish/Program.cs
+++ b/aeqw89.tools.Publish/Program.cs
@@ -238,9 +238,20 @@ public static class Program {
}
var outDir = Path.GetRandomFileName();
- result = AnsiConsole.Status()
+ Console.CancelKeyPress += (sender, eventArgs) => {
+ try {
+ Directory.Delete(outDir, true);
+ AnsiConsole.MarkupLine("[yellow]Cleaned up temporary directory[/]");
+ }
+ catch (Exception e) {
+ ShowError(string.Format(Exceptions.failed_to_clean_up.EscapeMarkup(), outDir.EscapeMarkup(),
+ e.ToString().EscapeMarkup()));
+ }
+ };
+
+ var exitCode = AnsiConsole.Status()
.Spinner(Spinner.Known.Dots)
- .Start("Creating package with 'dotnet pack' ", ctx => {
+ .Start("Creating package with 'dotnet pack' ", ctx => {
var p = Process.Start(new ProcessStartInfo() {
FileName = "dotnet",
Arguments = $"pack -o {outDir}",
@@ -250,11 +261,11 @@ public static class Program {
RedirectStandardError = !Verbose
});
p?.WaitForExit();
- return p?.ExitCode == 0;
+ return p?.ExitCode ?? -1;
});
- if (!result) {
- ShowError(Exceptions.dotnet_pack_failure.EscapeMarkup());
+ if (exitCode != 0) {
+ ShowError(Exceptions.dotnet_pack_failure.EscapeMarkup(), exitCode);
return;
}
@@ -270,7 +281,7 @@ public static class Program {
try {
await AnsiConsole.Progress()
.AutoClear(true)
- .HideCompleted(true)
+ .HideCompleted(false)
.Columns(new ProgressColumn[] {
new TaskDescriptionColumn(),
new ProgressBarColumn()