From c39b5741fca0445f5c1afd34e48080c54eb34d1d Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Mon, 18 Oct 2021 17:43:17 +0200 Subject: [PATCH] delete old build directories when renaming --- GameBundle/Program.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/GameBundle/Program.cs b/GameBundle/Program.cs index 36ad3e6..6ceca93 100644 --- a/GameBundle/Program.cs +++ b/GameBundle/Program.cs @@ -83,7 +83,10 @@ namespace GameBundle { Console.WriteLine("Couldn't determine build name, aborting"); return -1; } - buildDir.MoveTo(Path.Combine(buildDir.Parent.FullName, $"{name}-{buildDir.Name}")); + var dest = Path.Combine(buildDir.Parent.FullName, $"{name}-{buildDir.Name}"); + if (Directory.Exists(dest)) + Directory.Delete(dest, true); + buildDir.MoveTo(dest); if (options.Verbose) Console.WriteLine($"Moved build directory to {buildDir.FullName}"); } @@ -98,7 +101,8 @@ namespace GameBundle { // Zip the output if required if (options.Zip) { var zipLocation = Path.Combine(buildDir.Parent.FullName, $"{buildDir.Name}.zip"); - File.Delete(zipLocation); + if (File.Exists(zipLocation)) + File.Delete(zipLocation); ZipFile.CreateFromDirectory(buildDir.FullName, zipLocation, CompressionLevel.Optimal, true); buildDir.Delete(true); if (options.Verbose)