From 3540e91cc421fea1ca7cd1c03e703fa15f85125e Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 19 May 2021 21:18:54 +0200 Subject: [PATCH] Add preserving package output directory across sequential package builds --- Source/Tools/Flax.Build/Deploy/Deployer.cs | 4 ++-- Source/Tools/Flax.Build/Deploy/Deployment.Editor.cs | 4 ++++ Source/Tools/Flax.Build/Deploy/Deployment.Platforms.cs | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/Tools/Flax.Build/Deploy/Deployer.cs b/Source/Tools/Flax.Build/Deploy/Deployer.cs index 9b6ac7657..289f84795 100644 --- a/Source/Tools/Flax.Build/Deploy/Deployer.cs +++ b/Source/Tools/Flax.Build/Deploy/Deployer.cs @@ -82,8 +82,8 @@ namespace Flax.Deploy // Prepare the package output PackageOutputPath = Path.Combine(Globals.EngineRoot, string.Format("Package_{0}_{1:00}_{2:00000}", VersionMajor, VersionMinor, VersionBuild)); - Utilities.DirectoryDelete(PackageOutputPath); - Directory.CreateDirectory(PackageOutputPath); + if (!Directory.Exists(PackageOutputPath)) + Directory.CreateDirectory(PackageOutputPath); Log.Info(string.Empty); Log.Info(string.Empty); diff --git a/Source/Tools/Flax.Build/Deploy/Deployment.Editor.cs b/Source/Tools/Flax.Build/Deploy/Deployment.Editor.cs index 33dbdbb78..d847c3554 100644 --- a/Source/Tools/Flax.Build/Deploy/Deployment.Editor.cs +++ b/Source/Tools/Flax.Build/Deploy/Deployment.Editor.cs @@ -34,6 +34,7 @@ namespace Flax.Deploy // Prepare RootPath = Globals.EngineRoot; OutputPath = Path.Combine(Deployer.PackageOutputPath, "Editor"); + Utilities.DirectoryDelete(OutputPath); Directory.CreateDirectory(OutputPath); Log.Info(string.Empty); Log.Info("Deploy editor files"); @@ -130,12 +131,14 @@ namespace Flax.Deploy { // Use system tool (preserves executable file attributes and link files) editorPackageZipPath = Path.Combine(Deployer.PackageOutputPath, "FlaxEditorLinux.zip"); + Utilities.FileDelete(editorPackageZipPath); Utilities.Run("zip", "Editor.zip -r .", null, OutputPath, Utilities.RunOptions.None); File.Move(Path.Combine(OutputPath, "Editor.zip"), editorPackageZipPath); } else { editorPackageZipPath = Path.Combine(Deployer.PackageOutputPath, "Editor.zip"); + Utilities.FileDelete(editorPackageZipPath); using (ZipFile zip = new ZipFile()) { zip.AddDirectory(OutputPath); @@ -152,6 +155,7 @@ namespace Flax.Deploy { Log.Info("Compressing editor debug symbols files..."); editorPackageZipPath = Path.Combine(Deployer.PackageOutputPath, "EditorDebugSymbols.zip"); + Utilities.FileDelete(editorPackageZipPath); using (ZipFile zip = new ZipFile()) { zip.AddDirectory(Path.Combine(Deployer.PackageOutputPath, "EditorDebugSymbols")); diff --git a/Source/Tools/Flax.Build/Deploy/Deployment.Platforms.cs b/Source/Tools/Flax.Build/Deploy/Deployment.Platforms.cs index e9fc98acc..8c30beda1 100644 --- a/Source/Tools/Flax.Build/Deploy/Deployment.Platforms.cs +++ b/Source/Tools/Flax.Build/Deploy/Deployment.Platforms.cs @@ -24,6 +24,7 @@ namespace Flax.Deploy string platformName = platform.ToString(); string src = Path.Combine(platformsRoot, platformName); string dst = Path.Combine(Deployer.PackageOutputPath, platformName); + Utilities.DirectoryDelete(dst); // Deploy files { @@ -69,6 +70,7 @@ namespace Flax.Deploy Log.Info("Compressing platform files..."); var packageZipPath = Path.Combine(Deployer.PackageOutputPath, platformName + ".zip"); + Utilities.FileDelete(packageZipPath); using (ZipFile zip = new ZipFile()) { zip.AddDirectory(dst);