diff --git a/DNNpackager.csproj b/DNNpackager.csproj index cd6076e..78a5c6b 100644 --- a/DNNpackager.csproj +++ b/DNNpackager.csproj @@ -5,11 +5,11 @@ netcoreapp3.1 1.0.6 install.ico - 1.0.6.0 + 1.0.7.0 Nevoweb DCL Debug;Release;Razor - 1.0.6.0 + 1.0.7.0 diff --git a/Program.cs b/Program.cs index cde0bab..cae732c 100644 --- a/Program.cs +++ b/Program.cs @@ -32,15 +32,19 @@ public class Program private static bool _nocompile; + // options (args > 3) + private static bool _repofilesdelete; + static void Main(string[] args) { try { Console.WriteLine("##################### START DNNpackager ##################### "); - + // Sleep if we need to debug, so we can attach debugger //Thread.Sleep(10000); + _repofilesdelete = false; // Delete files in the website that don't exist in the repo; if (args.Length >= 1) { if (args.Length == 1) Console.ReadKey(); // wait for keypress if we run direct from File Explorer. @@ -60,6 +64,9 @@ static void Main(string[] args) binSource = args[1]; configurationName = args[2].ToLower(); } + + if (args.Contains("/clean")) _repofilesdelete = true; + if (configurationName == "razor" || configurationName.StartsWith("nc-")) _nocompile = true; var configPath = args[0]; @@ -78,6 +85,7 @@ static void Main(string[] args) Console.WriteLine("ProjectFolder: " + _sourceRootPath); Console.WriteLine("binSource: " + binSource); Console.WriteLine("ConfigurationName: " + configurationName); + Console.WriteLine("Clean: " + _repofilesdelete.ToString()); if (Directory.Exists(_sourceRootPath) && File.Exists(configPath)) { @@ -297,20 +305,25 @@ static void SyncAll(DirectoryInfo gitDir, DirectoryInfo webDir) } } // remove any files in webiste that do not exists in the Git Repo - foreach (var fi in webList) + // This process is a problem for plugins, where files may have been added to the project at runtime. + // We therefore only delete files when the "/clean" options has been added to the command args[]. + if (_repofilesdelete) { - if (Path.GetExtension(fi.Name) == "") - { - Console.WriteLine("WARNING: No file extension. (Not Processed) " + fi.FullName); - } - else + foreach (var fi in webList) { - if (!gitListNames.Contains(Path.GetFileName(fi.Name))) + if (Path.GetExtension(fi.Name) == "") + { + Console.WriteLine("WARNING: No file extension. (Not Processed) " + fi.FullName); + } + else { - if (Path.GetExtension(fi.Name) != "") + if (!gitListNames.Contains(Path.GetFileName(fi.Name))) { - File.Delete(Path.Combine(webDir.FullName, fi.Name)); - Console.WriteLine("Delete: " + Path.Combine(webDir.FullName, fi.Name)); + if (Path.GetExtension(fi.Name) != "") + { + File.Delete(Path.Combine(webDir.FullName, fi.Name)); + Console.WriteLine("Delete: " + Path.Combine(webDir.FullName, fi.Name)); + } } } } diff --git a/README.md b/README.md index b093bbe..adbfba8 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,12 @@ arg2 - **\** = The bin folder of the source module. In VS tokens it arg3 - **\** = The VS configuration. \$(ConfigurationName) (optional) +**"/clean"** option can be added to the command. This option will delete files on the "copy website" that do not exist in the project. Use caution when using this, runtime files that have been added for plugin operations will be removed. + +``` +DNNpackager.exe $(ProjectDir) $(ProjectDir)$(OutDir) $(ConfigurationName) /clean +``` + Example from VS post build event: ```