Skip to content

Commit

Permalink
Support copying dependencies when going for cold-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
synhershko committed Jun 28, 2012
1 parent 22cbe89 commit 88e2e09
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/NAppUpdate.Framework/Common/NauConfigurations.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;

namespace NAppUpdate.Framework.Common
Expand Down Expand Up @@ -39,5 +40,14 @@ public string BackupFolder
/// an UAC prompt in all cases.
/// </summary>
public string UpdateExecutableName { get; set; }

/// <summary>
/// A list of files (relative paths only) to be copied along with the NAppUpdate DLL and updater host
/// when performing cold updates. You need to set this only when you have a custom IUpdateTask that
/// takes dependency of an external DLL, or require other files side by side with them.
/// Custom IUpdateTasks taking dependencies of external DLLs which may require cold update, MUST reside
/// in an external class-library, never in the application EXE, for that reason.
/// </summary>
public List<string> DependenciesForColdUpdate { get; set; }
}
}
16 changes: 15 additions & 1 deletion src/NAppUpdate.Framework/Utils/NauIpc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,21 @@ internal static void ExtractUpdaterFromResource(string updaterPath, string hostE
File.Copy(assemblyLocation, Path.Combine(updaterPath, "NAppUpdate.Framework.dll"));

// And also all other referenced DLLs (opt-in only)
// TODO typeof(UpdateStarter).Assembly.GetReferencedAssemblies()
var assemblyPath = Path.GetDirectoryName(assemblyLocation) ?? string.Empty;
if (UpdateManager.Instance.Config.DependenciesForColdUpdate != null)
{
// TODO Maybe we can back this up with typeof(UpdateStarter).Assembly.GetReferencedAssemblies()

foreach (var dep in UpdateManager.Instance.Config.DependenciesForColdUpdate)
{
string fullPath = Path.Combine(assemblyPath, dep);
if (!File.Exists(fullPath)) continue;

var dest = Path.Combine(updaterPath, dep);
FileSystem.CreateDirectoryStructure(dest);
File.Copy(fullPath, Path.Combine(updaterPath, dep));
}
}
}
}
}

0 comments on commit 88e2e09

Please sign in to comment.