static void Main(string[] args) { try { Debug.Assert(false); if (!args.Any()) { string distroFile = UserInputForm.GetDistro(); if (!string.IsNullOrEmpty(distroFile)) { // Debug.Assert(false); StopVBCSCompilers(); if (EnsureNppNotRunning(false) && EnsureVBCSCompilerNotLocked(false)) { if (distroFile.StartsWith("http")) { var url = distroFile; distroFile = Path.Combine(KnownFolders.UserDownloads, "CSScriptNpp.ManualUpdate", Path.GetFileName(distroFile)); WebHelper.DownloadBinary(url, distroFile); } DeployItselfAndRestart(distroFile, FindPluginDir(distroFile)); } } return; } bool createdNew; appSingleInstanceMutex = new Mutex(true, "Npp.CSScript.PluginUpdater", out createdNew); if (!createdNew) { MessageBox.Show($"Another Notepad++ plugin update in progress. Either wait or stop {Path.GetFileName(Assembly.GetExecutingAssembly().Location)}", "CS-Script"); return; } // <zipFile> [<pluginDir>] [/asynchUpdateArg] string zipFile = args[0]; string pluginDir = args.Length > 1 ? args[1] : FindPluginDir(zipFile); string updaterDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); if (updaterDir.StartsWith(pluginDir, StringComparison.OrdinalIgnoreCase)) { DeployItselfAndRestart(zipFile, pluginDir); return; } else { DeployDependencies(); } if (IsAdmin()) { StopVBCSCompilers(); bool isAsynchUpdate = args.Contains(asynchUpdateArg) || args.First().IsUrl() || args.First().IsVersion(); args = args.Where(x => x != asynchUpdateArg).ToArray(); if (pluginDir == null) { throw new Exception($"Cannot find Notepad++ installation."); } // Debug.Assert(false); if (EnsureNppNotRunning(isAsynchUpdate) && EnsureVBCSCompilerNotLocked(isAsynchUpdate)) { if (isAsynchUpdate) { WaitPrompt.Show(); string arg = args[0]; zipFile = WebHelper.DownloadDistro(args[0], WaitPrompt.OnProgress); } // pluginDir: C:\Program Files\Notepad++\plugins\CSScriptNpp Updater.Deploy(zipFile, Path.GetDirectoryName(pluginDir)); WaitPrompt.Hide(); if (EnsureNppNotRunning(isAsynchUpdate) && EnsureVBCSCompilerNotLocked(isAsynchUpdate)) { MessageBox.Show("The update process has been completed.", "CS-Script Update"); } } } else { throw new Exception("You need admin rights to start CS-Script updater."); } } catch (Exception e) { WaitPrompt.Hide(); MessageBox.Show("Update has not succeeded.\nError: " + e.Message, "CS-Script Update"); } }