int main(string[] args) { // NB: Trying to delete the app directory while we have Setup.log // open will actually crash the uninstaller bool isUninstalling = args.Any(x => x.Contains("uninstall")); // Uncomment to test Gifs //AnimatedGifWindow.ShowWindow(TimeSpan.FromMilliseconds(0), animatedGifWindowToken.Token); //Thread.Sleep(10 * 60 * 1000); using (var logger = new SetupLogLogger(isUninstalling) { Level = LogLevel.Info }) { Locator.CurrentMutable.Register(() => logger, typeof(Splat.ILogger)); try { return(executeCommandLine(args)); } catch (Exception ex) { logger.Write("Unhandled exception: " + ex, LogLevel.Fatal); throw; } // Ideally we would deregister the logger from the Locator before it was disposed - this is a hazard as it is at the moment } }
int main(string[] args) { try { opt = new StartupOption(args); } catch (Exception ex) { using (var logger = new SetupLogLogger(true, "OptionParsing") { Level = LogLevel.Info }) { Locator.CurrentMutable.Register(() => logger, typeof(Splat.ILogger)); logger.Write($"Failed to parse command line options. {ex.Message}", LogLevel.Error); } throw; } // NB: Trying to delete the app directory while we have Setup.log // open will actually crash the uninstaller bool isUninstalling = opt.updateAction == UpdateAction.Uninstall; using (var logger = new SetupLogLogger(isUninstalling, opt.updateAction.ToString()) { Level = LogLevel.Info }) { Locator.CurrentMutable.Register(() => logger, typeof(Splat.ILogger)); try { return(executeCommandLine(args)); } catch (Exception ex) { logger.Write("Finished with unhandled exception: " + ex, LogLevel.Fatal); throw; } } }
int main(string[] args) { using (var logger = new SetupLogLogger() {Level = LogLevel.Info}) { Locator.CurrentMutable.Register(() => logger, typeof (Splat.ILogger)); try { return executeCommandLine(args, logger.LogPath); } catch (Exception ex) { logger.Write("Unhandled exception: " + ex, LogLevel.Fatal); throw; } // Ideally we would deregister the logger from the Locator before it was disposed - this is a hazard as it is at the moment } }
int main(string[] args) { using (var logger = new SetupLogLogger() { Level = LogLevel.Info }) { Locator.CurrentMutable.Register(() => logger, typeof(Splat.ILogger)); try { return(executeCommandLine(args, logger.LogPath)); } catch (Exception ex) { logger.Write("Unhandled exception: " + ex, LogLevel.Fatal); throw; } // Ideally we would deregister the logger from the Locator before it was disposed - this is a hazard as it is at the moment } }
int main(string[] args) { // NB: Trying to delete the app directory while we have Setup.log // open will actually crash the uninstaller bool isUninstalling = args.Any(x => x.Contains("uninstall")); using (var logger = new SetupLogLogger(isUninstalling) {Level = LogLevel.Info}) { Locator.CurrentMutable.Register(() => logger, typeof (Splat.ILogger)); try { return executeCommandLine(args); } catch (Exception ex) { logger.Write("Unhandled exception: " + ex, LogLevel.Fatal); throw; } } }
int main(string[] args) { // NB: Trying to delete the app directory while we have Setup.log // open will actually crash the uninstaller bool isUninstalling = args.Any(x => x.Contains("uninstall")); // Uncomment to test Gifs //AnimatedGifWindow.ShowWindow(TimeSpan.FromMilliseconds(0), animatedGifWindowToken.Token); //Thread.Sleep(10 * 60 * 1000); using (var logger = new SetupLogLogger(isUninstalling) {Level = LogLevel.Info}) { Locator.CurrentMutable.Register(() => logger, typeof (Splat.ILogger)); try { return executeCommandLine(args); } catch (Exception ex) { logger.Write("Unhandled exception: " + ex, LogLevel.Fatal); throw; } // Ideally we would deregister the logger from the Locator before it was disposed - this is a hazard as it is at the moment } }
int main(string[] args) { var animatedGifWindowToken = new CancellationTokenSource(); // NB: Trying to delete the app directory while we have Setup.log // open will actually crash the uninstaller bool isUninstalling = args.Any(x => x.Contains("uninstall")); // Uncomment to test Gifs //AnimatedGifWindow.ShowWindow(TimeSpan.FromMilliseconds(0), animatedGifWindowToken.Token); //Thread.Sleep(10 * 60 * 1000); using (Disposable.Create(() => animatedGifWindowToken.Cancel())) using (var logger = new SetupLogLogger(isUninstalling) { Level = Splat.LogLevel.Info }) { Splat.Locator.CurrentMutable.Register(() => logger, typeof(Splat.ILogger)); this.Log().Info("Starting Squirrel Updater: " + String.Join(" ", args)); if (args.Any(x => x.StartsWith("/squirrel", StringComparison.OrdinalIgnoreCase))) { // NB: We're marked as Squirrel-aware, but we don't want to do // anything in response to these events return(0); } bool silentInstall = false; var updateAction = default(UpdateAction); string target = default(string); string releaseDir = default(string); string packagesDir = default(string); string bootstrapperExe = default(string); string backgroundGif = default(string); string signingParameters = default(string); string baseUrl = default(string); string processStart = default(string); string processStartArgs = default(string); string appName = default(string); string setupIcon = default(string); string shortcutArgs = default(string); opts = new OptionSet() { "Usage: Squirrel.exe command [OPTS]", "Manages Squirrel packages", "", "Commands", { "install=", "Install the app whose package is in the specified directory", v => { updateAction = UpdateAction.Install; target = v; } }, { "uninstall", "Uninstall the app the same dir as Update.exe", v => updateAction = UpdateAction.Uninstall }, { "download=", "Download the releases specified by the URL and write new results to stdout as JSON", v => { updateAction = UpdateAction.Download; target = v; } }, { "update=", "Update the application to the latest remote version specified by URL", v => { updateAction = UpdateAction.Update; target = v; } }, { "releasify=", "Update or generate a releases directory with a given NuGet package", v => { updateAction = UpdateAction.Releasify; target = v; } }, { "createShortcut=", "Create a shortcut for the given executable name", v => { updateAction = UpdateAction.Shortcut; target = v; } }, { "removeShortcut=", "Remove a shortcut for the given executable name", v => { updateAction = UpdateAction.Deshortcut; target = v; } }, { "updateSelf=", "Copy the currently executing Update.exe into the default location", v => { updateAction = UpdateAction.UpdateSelf; appName = v; } }, { "processStart=", "Start an executable in the latest version of the app package", v => { updateAction = UpdateAction.ProcessStart; processStart = v; }, true }, "", "Options:", { "h|?|help", "Display Help and exit", _ => {} }, { "r=|releaseDir=", "Path to a release directory to use with releasify", v => releaseDir = v }, { "p=|packagesDir=", "Path to the NuGet Packages directory for C# apps", v => packagesDir = v }, { "bootstrapperExe=", "Path to the Setup.exe to use as a template", v => bootstrapperExe = v }, { "g=|loadingGif=", "Path to an animated GIF to be displayed during installation", v => backgroundGif = v }, { "i=|setupIcon", "Path to an ICO file that will be used for the Setup executable's icon", v => setupIcon = v }, { "n=|signWithParams=", "Sign the installer via SignTool.exe with the parameters given", v => signingParameters = v }, { "s|silent", "Silent install", _ => silentInstall = true }, { "b=|baseUrl=", "Provides a base URL to prefix the RELEASES file packages with", v => baseUrl = v, true }, { "a=|process-start-args=", "Arguments that will be used when starting executable", v => processStartArgs = v, true }, { "l=|shortcut-locations=", "Comma-separated string of shortcut locations, e.g. 'Desktop,StartMenu'", v => shortcutArgs = v }, }; opts.Parse(args); if (updateAction == UpdateAction.Unset) { ShowHelp(); return(-1); } switch (updateAction) { case UpdateAction.Install: var progressSource = new ProgressSource(); if (!silentInstall) { AnimatedGifWindow.ShowWindow(TimeSpan.FromSeconds(4), animatedGifWindowToken.Token, progressSource); } Install(silentInstall, progressSource, Path.GetFullPath(target)).Wait(); break; case UpdateAction.Uninstall: Uninstall().Wait(); break; case UpdateAction.Download: Console.WriteLine(Download(target).Result); break; case UpdateAction.Update: Update(target).Wait(); break; case UpdateAction.UpdateSelf: UpdateSelf(appName).Wait(); break; case UpdateAction.Releasify: Releasify(target, releaseDir, packagesDir, bootstrapperExe, backgroundGif, signingParameters, baseUrl, setupIcon); break; case UpdateAction.Shortcut: Shortcut(target, shortcutArgs); break; case UpdateAction.Deshortcut: Deshortcut(target, shortcutArgs); break; case UpdateAction.ProcessStart: ProcessStart(processStart, processStartArgs); break; } } return(0); }
int main(string[] args) { var animatedGifWindowToken = new CancellationTokenSource(); // NB: Trying to delete the app directory while we have Setup.log // open will actually crash the uninstaller bool isUninstalling = args.Any(x => x.Contains("uninstall")); // Uncomment to test Gifs //AnimatedGifWindow.ShowWindow(TimeSpan.FromMilliseconds(0), animatedGifWindowToken.Token); //Thread.Sleep(10 * 60 * 1000); using (Disposable.Create(() => animatedGifWindowToken.Cancel())) using (var logger = new SetupLogLogger(isUninstalling) { Level = Splat.LogLevel.Info }) { Splat.Locator.CurrentMutable.Register(() => logger, typeof(Splat.ILogger)); this.Log().Info("Starting Squirrel Updater: " + String.Join(" ", args)); if (args.Any(x => x.StartsWith("/squirrel", StringComparison.OrdinalIgnoreCase))) { // NB: We're marked as Squirrel-aware, but we don't want to do // anything in response to these events return 0; } bool silentInstall = false; var updateAction = default(UpdateAction); string target = default(string); string releaseDir = default(string); string packagesDir = default(string); string bootstrapperExe = default(string); string backgroundGif = default(string); string signingParameters = default(string); string baseUrl = default(string); string processStart = default(string); string processStartArgs = default(string); string appName = default(string); opts = new OptionSet() { "Usage: Squirrel.exe command [OPTS]", "Manages Squirrel packages", "", "Commands", { "install=", "Install the app whose package is in the specified directory", v => { updateAction = UpdateAction.Install; target = v; } }, { "uninstall", "Uninstall the app the same dir as Update.exe", v => updateAction = UpdateAction.Uninstall}, { "download=", "Download the releases specified by the URL and write new results to stdout as JSON", v => { updateAction = UpdateAction.Download; target = v; } }, { "update=", "Update the application to the latest remote version specified by URL", v => { updateAction = UpdateAction.Update; target = v; } }, { "releasify=", "Update or generate a releases directory with a given NuGet package", v => { updateAction = UpdateAction.Releasify; target = v; } }, { "createShortcut=", "Create a shortcut for the given executable name", v => { updateAction = UpdateAction.Shortcut; target = v; } }, { "removeShortcut=", "Remove a shortcut for the given executable name", v => { updateAction = UpdateAction.Deshortcut; target = v; } }, { "updateSelf=", "Copy the currently executing Update.exe into the default location", v => { updateAction = UpdateAction.UpdateSelf; appName = v; } }, { "processStart=", "Start an executable in the latest version of the app package", v => { updateAction = UpdateAction.ProcessStart; processStart = v; }, true}, "", "Options:", { "h|?|help", "Display Help and exit", _ => {} }, { "r=|releaseDir=", "Path to a release directory to use with releasify", v => releaseDir = v}, { "p=|packagesDir=", "Path to the NuGet Packages directory for C# apps", v => packagesDir = v}, { "bootstrapperExe=", "Path to the Setup.exe to use as a template", v => bootstrapperExe = v}, { "g=|loadingGif=", "Path to an animated GIF to be displayed during installation", v => backgroundGif = v}, { "n=|signWithParams=", "Sign the installer via SignTool.exe with the parameters given", v => signingParameters = v}, { "s|silent", "Silent install", _ => silentInstall = true}, { "b=|baseUrl=", "Provides a base URL to prefix the RELEASES file packages with", v => baseUrl = v, true}, { "a=|process-start-args=", "Arguments that will be used when starting executable", v => processStartArgs = v, true}, }; opts.Parse(args); if (updateAction == UpdateAction.Unset) { ShowHelp(); return -1; } switch (updateAction) { case UpdateAction.Install: AnimatedGifWindow.ShowWindow(TimeSpan.FromSeconds(4), animatedGifWindowToken.Token); Install(silentInstall, Path.GetFullPath(target)).Wait(); break; case UpdateAction.Uninstall: Uninstall().Wait(); break; case UpdateAction.Download: Console.WriteLine(Download(target).Result); break; case UpdateAction.Update: Update(target).Wait(); break; case UpdateAction.UpdateSelf: UpdateSelf(appName).Wait(); break; case UpdateAction.Releasify: Releasify(target, releaseDir, packagesDir, bootstrapperExe, backgroundGif, signingParameters, baseUrl); break; case UpdateAction.Shortcut: Shortcut(target); break; case UpdateAction.Deshortcut: Deshortcut(target); break; case UpdateAction.ProcessStart: ProcessStart(processStart, processStartArgs); break; } } return 0; }
int main(string[] args) { // NB: Trying to delete the app directory while we have Setup.log // open will actually crash the uninstaller bool isUninstalling = args.Any(x => x.Contains("uninstall")); using (var logger = new SetupLogLogger(isUninstalling) { Level = Splat.LogLevel.Info }) { Splat.Locator.CurrentMutable.Register(() => logger, typeof(Splat.ILogger)); this.Log().Info("Starting Squirrel Updater: " + String.Join(" ", args)); if (args.Any(x => x.StartsWith("/squirrel", StringComparison.OrdinalIgnoreCase))) { // NB: We're marked as Squirrel-aware, but we don't want to do // anything in response to these events return(0); } bool silentInstall = false; var updateAction = default(UpdateAction); string target = default(string); string releaseDir = default(string); string packagesDir = default(string); string bootstrapperExe = default(string); opts = new OptionSet() { "Usage: Update.exe command [OPTS]", "Manages Squirrel packages", "", "Commands", { "install=", "Install the app whose package is in the specified directory", v => { updateAction = UpdateAction.Install; target = v; } }, { "uninstall", "Uninstall the app the same dir as Update.exe", v => updateAction = UpdateAction.Uninstall }, { "download=", "Download the releases specified by the URL and write new results to stdout as JSON", v => { updateAction = UpdateAction.Download; target = v; } }, { "update=", "Update the application to the latest remote version specified by URL", v => { updateAction = UpdateAction.Update; target = v; } }, { "releasify=", "Update or generate a releases directory with a given NuGet package", v => { updateAction = UpdateAction.Releasify; target = v; } }, "", "Options:", { "h|?|help", "Display Help and exit", _ => ShowHelp() }, { "r=|releaseDir=", "Path to a release directory to use with releasify", v => releaseDir = v }, { "p=|packagesDir=", "Path to the NuGet Packages directory for C# apps", v => packagesDir = v }, { "bootstrapperExe=", "Path to the Setup.exe to use as a template", v => bootstrapperExe = v }, { "s|silent", "Silent install", _ => silentInstall = true }, }; opts.Parse(args); if (updateAction == UpdateAction.Unset) { ShowHelp(); } switch (updateAction) { case UpdateAction.Install: Install(silentInstall, Path.GetFullPath(target)).Wait(); break; case UpdateAction.Uninstall: Uninstall().Wait(); break; case UpdateAction.Download: Console.WriteLine(Download(target).Result); break; case UpdateAction.Update: Update(target).Wait(); break; case UpdateAction.Releasify: Releasify(target, releaseDir, packagesDir, bootstrapperExe); break; } } return(0); }
int main(string[] args) { // NB: Trying to delete the app directory while we have Setup.log // open will actually crash the uninstaller bool isUninstalling = args.Any(x => x.Contains("uninstall")); using (var logger = new SetupLogLogger(isUninstalling) { Level = Splat.LogLevel.Info }) { Splat.Locator.CurrentMutable.Register(() => logger, typeof(Splat.ILogger)); this.Log().Info("Starting Squirrel Updater: " + String.Join(" ", args)); if (args.Any(x => x.StartsWith("/squirrel", StringComparison.OrdinalIgnoreCase))) { // NB: We're marked as Squirrel-aware, but we don't want to do // anything in response to these events return 0; } bool silentInstall = false; var updateAction = default(UpdateAction); string target = default(string); string releaseDir = default(string); string packagesDir = default(string); string bootstrapperExe = default(string); opts = new OptionSet() { "Usage: Update.exe command [OPTS]", "Manages Squirrel packages", "", "Commands", { "install=", "Install the app whose package is in the specified directory", v => { updateAction = UpdateAction.Install; target = v; } }, { "uninstall", "Uninstall the app the same dir as Update.exe", v => updateAction = UpdateAction.Uninstall}, { "download=", "Download the releases specified by the URL and write new results to stdout as JSON", v => { updateAction = UpdateAction.Download; target = v; } }, { "update=", "Update the application to the latest remote version specified by URL", v => { updateAction = UpdateAction.Update; target = v; } }, { "releasify=", "Update or generate a releases directory with a given NuGet package", v => { updateAction = UpdateAction.Releasify; target = v; } }, "", "Options:", { "h|?|help", "Display Help and exit", _ => ShowHelp() }, { "r=|releaseDir=", "Path to a release directory to use with releasify", v => releaseDir = v}, { "p=|packagesDir=", "Path to the NuGet Packages directory for C# apps", v => packagesDir = v}, { "bootstrapperExe=", "Path to the Setup.exe to use as a template", v => bootstrapperExe = v}, { "s|silent", "Silent install", _ => silentInstall = true}, }; opts.Parse(args); if (updateAction == UpdateAction.Unset) { ShowHelp(); } switch (updateAction) { case UpdateAction.Install: Install(silentInstall, Path.GetFullPath(target)).Wait(); break; case UpdateAction.Uninstall: Uninstall().Wait(); break; case UpdateAction.Download: Console.WriteLine(Download(target).Result); break; case UpdateAction.Update: Update(target).Wait(); break; case UpdateAction.Releasify: Releasify(target, releaseDir, packagesDir, bootstrapperExe); break; } } return 0; }