From ad729133a672c2fd48b9684bbd33e95e18ac92df Mon Sep 17 00:00:00 2001 From: qwsdcvghyu89 <61093706+qwsdcvghyu89@users.noreply.github.com> Date: Sat, 27 Sep 2025 15:56:20 +1000 Subject: [PATCH] Restore project file on cancel event Adds a handler for Console.CancelKeyPress to restore the project file from backup if the process is interrupted, ensuring changes are not left in an inconsistent state. --- aeqw89.tools.Publish/Program.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/aeqw89.tools.Publish/Program.cs b/aeqw89.tools.Publish/Program.cs index 6c7e040..7e00f73 100644 --- a/aeqw89.tools.Publish/Program.cs +++ b/aeqw89.tools.Publish/Program.cs @@ -124,6 +124,11 @@ public static class Program { try { projectFile.Backup(); + Console.CancelKeyPress += (sender, eventArgs) => { + projectFile.Restore(); + AnsiConsole.MarkupLine("[yellow]Restored project file from backup.[/]"); + }; + if (Verbose) AnsiConsole.WriteLine( $"Created project file backup at {projectFile.GetDefaultBackupLocation()}");