delete old build directories when renaming

This commit is contained in:
Ell 2021-10-18 17:43:17 +02:00
parent bab7836c05
commit c39b5741fc

View file

@ -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,6 +101,7 @@ namespace GameBundle {
// Zip the output if required
if (options.Zip) {
var zipLocation = Path.Combine(buildDir.Parent.FullName, $"{buildDir.Name}.zip");
if (File.Exists(zipLocation))
File.Delete(zipLocation);
ZipFile.CreateFromDirectory(buildDir.FullName, zipLocation, CompressionLevel.Optimal, true);
buildDir.Delete(true);