diff --git a/src/NAppUpdate.Framework/Common/NauConfigurations.cs b/src/NAppUpdate.Framework/Common/NauConfigurations.cs index f34c4d41..1967415e 100644 --- a/src/NAppUpdate.Framework/Common/NauConfigurations.cs +++ b/src/NAppUpdate.Framework/Common/NauConfigurations.cs @@ -1,53 +1,54 @@ -using System; -using System.Collections.Generic; -using System.IO; - -namespace NAppUpdate.Framework.Common -{ - [Serializable] - public class NauConfigurations - { - public string TempFolder { get; set; } - - /// - /// Path to the backup folder used by the update process - /// - public string BackupFolder - { - set - { - if (UpdateManager.Instance.State == UpdateManager.UpdateProcessState.NotChecked - || UpdateManager.Instance.State == UpdateManager.UpdateProcessState.Checked) - { - string path = value.TrimEnd(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); - _backupFolder = Path.IsPathRooted(path) ? path : Path.Combine(TempFolder, path); - } - else - throw new ArgumentException("BackupFolder can only be specified before update has started"); - } - get - { - return _backupFolder; - } - } - internal string _backupFolder; - - public string UpdateProcessName { get; set; } - - /// - /// The name for the executable file to extract and run cold updates with. Default is foo.exe. You can change - /// it to whatever you want, but pay attention to names like "updater.exe" and "installer.exe" - they will trigger - /// an UAC prompt in all cases. - /// - public string UpdateExecutableName { get; set; } - - /// - /// 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. - /// - public List DependenciesForColdUpdate { get; set; } - } -} +using System; +using System.Collections.Generic; +using System.IO; + +namespace NAppUpdate.Framework.Common +{ + [Serializable] + public class NauConfigurations + { + public string TempFolder { get; set; } + public string RelaunchAppArgs { get; set; } + + /// + /// Path to the backup folder used by the update process + /// + public string BackupFolder + { + set + { + if (UpdateManager.Instance.State == UpdateManager.UpdateProcessState.NotChecked + || UpdateManager.Instance.State == UpdateManager.UpdateProcessState.Checked) + { + string path = value.TrimEnd(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); + _backupFolder = Path.IsPathRooted(path) ? path : Path.Combine(TempFolder, path); + } + else + throw new ArgumentException("BackupFolder can only be specified before update has started"); + } + get + { + return _backupFolder; + } + } + internal string _backupFolder; + + public string UpdateProcessName { get; set; } + + /// + /// The name for the executable file to extract and run cold updates with. Default is foo.exe. You can change + /// it to whatever you want, but pay attention to names like "updater.exe" and "installer.exe" - they will trigger + /// an UAC prompt in all cases. + /// + public string UpdateExecutableName { get; set; } + + /// + /// 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. + /// + public List DependenciesForColdUpdate { get; set; } + } +} diff --git a/src/NAppUpdate.Framework/UpdateManager.cs b/src/NAppUpdate.Framework/UpdateManager.cs index 36ffbd19..e36ba110 100644 --- a/src/NAppUpdate.Framework/UpdateManager.cs +++ b/src/NAppUpdate.Framework/UpdateManager.cs @@ -143,13 +143,21 @@ public void CheckForUpdates() lock (UpdatesToApply) { UpdatesToApply.Clear(); - var tasks = UpdateFeedReader.Read(UpdateSource.GetUpdatesFeed()); - foreach (var t in tasks) + float num = 0f; + var tasks = UpdateFeedReader.Read(UpdateSource.GetUpdatesFeed()); + int count = tasks.Count; + foreach (var t in tasks) { if (ShouldStop) throw new UserAbortException(); - - if (t.UpdateConditions == null || t.UpdateConditions.IsMet(t)) // Only execute if all conditions are met + this.ReportProgress(new UpdateProgressInfo { + Message = "Checking", + Percentage = (int)((num += 1f) / (float)count * 100f), + TaskDescription = t.Description, + TaskId = (int)num, + StillWorking = true + }); + if (t.UpdateConditions == null || t.UpdateConditions.IsMet(t)) // Only execute if all conditions are met UpdatesToApply.Add(t); } } @@ -238,8 +246,9 @@ public void PrepareUpdates() var t = task; task.ProgressDelegate += status => TaskProgressCallback(status, t); - - try + this.TaskProgressCallback(new UpdateProgressInfo{ + Message = "Preparing"}, t); + try { task.Prepare(UpdateSource); } @@ -402,8 +411,9 @@ public void ApplyUpdates(bool relaunchApplication, bool updaterDoLogging, bool u { IUpdateTask t = task; task.ProgressDelegate += status => TaskProgressCallback(status, t); - - try + this.TaskProgressCallback(new UpdateProgressInfo{ + Message = "Applying"}, t); + try { // Execute the task task.ExecutionStatus = task.Execute(false); diff --git a/src/NAppUpdate.Framework/Updater/updater.exe b/src/NAppUpdate.Framework/Updater/updater.exe index 94c4caa2..bc511d5c 100644 Binary files a/src/NAppUpdate.Framework/Updater/updater.exe and b/src/NAppUpdate.Framework/Updater/updater.exe differ diff --git a/src/NAppUpdate.Updater/AppStart.cs b/src/NAppUpdate.Updater/AppStart.cs index 825206db..5e22f68f 100644 --- a/src/NAppUpdate.Updater/AppStart.cs +++ b/src/NAppUpdate.Updater/AppStart.cs @@ -137,8 +137,9 @@ private static void PerformUpdates() // Get some required environment variables string appPath = _dto.AppPath; string appDir = _dto.WorkingDirectory ?? Path.GetDirectoryName(appPath) ?? string.Empty; + string relaunchAppArgs = _dto.Configs.RelaunchAppArgs; - if (!string.IsNullOrEmpty(_dto.AppPath)) + if (!string.IsNullOrEmpty(_dto.AppPath)) { _logFilePath = Path.Combine(Path.GetDirectoryName(_dto.AppPath), @"NauUpdate.log"); // now we can log to a more accessible location } @@ -205,7 +206,7 @@ private static void PerformUpdates() UseShellExecute = useShellExecute, WorkingDirectory = appDir, FileName = appPath, - Arguments = "-nappupdate-afterrestart" + Arguments = "-nappupdate-afterrestart" + " " + relaunchAppArgs }; try