diff --git a/src/Build/src/ClearPluginAssemblies/Program.cs b/src/Build/src/ClearPluginAssemblies/Program.cs index d01cdf56acc..3c2fcad5c73 100644 --- a/src/Build/src/ClearPluginAssemblies/Program.cs +++ b/src/Build/src/ClearPluginAssemblies/Program.cs @@ -41,6 +41,9 @@ protected static void Clear(string paths, IList fileNames, bool saveLoca if (directoryInfo.GetFiles().Length == 0 && directoryInfo.GetDirectories().Length == 0 && !saveLocalesFolders) directoryInfo.Delete(true); } + + // Delete runtimes folder after clearing assemblies + DeleteRuntimesFolder(pluginPath); } catch { @@ -49,6 +52,30 @@ protected static void Clear(string paths, IList fileNames, bool saveLoca } } + /// + /// Deletes the runtimes folder from the plugin directory. + /// The runtimes folder contains platform-specific native libraries for cross-platform support. + /// Since we build for a specific OS, these folders are unnecessary and waste disk space. + /// + /// The path to the plugin directory + protected static void DeleteRuntimesFolder(string pluginPath) + { + try + { + var runtimesPath = Path.Combine(pluginPath, "runtimes"); + if (Directory.Exists(runtimesPath)) + { + Directory.Delete(runtimesPath, recursive: true); + Console.WriteLine($"Deleted runtimes folder from: {pluginPath}"); + } + } + catch (Exception ex) + { + // Log the error but don't fail the build + Console.WriteLine($"Warning: Could not delete runtimes folder from {pluginPath}: {ex.Message}"); + } + } + private static void Main(string[] args) { var outputPath = string.Empty; @@ -56,7 +83,7 @@ private static void Main(string[] args) var saveLocalesFolders = true; var settings = args.FirstOrDefault(a => a.Contains('|')) ?? string.Empty; - if(string.IsNullOrEmpty(settings)) + if (string.IsNullOrEmpty(settings)) return; foreach (var arg in settings.Split('|')) @@ -79,8 +106,8 @@ private static void Main(string[] args) break; } } - - if(!Directory.Exists(outputPath)) + + if (!Directory.Exists(outputPath)) return; var di = new DirectoryInfo(outputPath);