Skip to content

Commit

Permalink
v1.0.7 - /clean option
Browse files Browse the repository at this point in the history
  • Loading branch information
leedavi committed Jul 13, 2021
1 parent db7c8e2 commit a820805
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
4 changes: 2 additions & 2 deletions DNNpackager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
<Version>1.0.6</Version>
<ApplicationIcon>install.ico</ApplicationIcon>
<AssemblyVersion>1.0.6.0</AssemblyVersion>
<AssemblyVersion>1.0.7.0</AssemblyVersion>
<Company>Nevoweb</Company>
<Authors>DCL</Authors>
<Configurations>Debug;Release;Razor</Configurations>
<FileVersion>1.0.6.0</FileVersion>
<FileVersion>1.0.7.0</FileVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
35 changes: 24 additions & 11 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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];
Expand All @@ -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))
{
Expand Down Expand Up @@ -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));
}
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ arg2 - **\<BinSource\>** = The bin folder of the source module. In VS tokens it

arg3 - **\<ConfigurationName\>** = 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:
```
Expand Down

0 comments on commit a820805

Please sign in to comment.