public static void HandleUrl(string url, MetroWindow window)
        {
            url = WebUtility.UrlDecode(url.Remove(0, FullName.Length));

            var r = Regex.Matches(url, "(project|profile)/([^/]*)/([^/]*)/([^/]*)/?");

            foreach (Match m in r)
            {
                var linkType       = m.Groups[1].ToString();
                var gitHubUser     = m.Groups[2].ToString();
                var repositoryName = m.Groups[3].ToString();
                var assemblyName   = m.Groups[4].ToString();

                switch (linkType)
                {
                case "project":
                    var w = new InstallerWindow {
                        Owner = window
                    };
                    w.ListAssemblies(
                        string.Format("https://github.com/{0}/{1}", gitHubUser, repositoryName), true,
                        assemblyName != "" ? m.Groups[4].ToString() : null);
                    w.ShowDialog();
                    break;

                case "profile":
                    break;
                }
            }
        }
Example #2
0
        public static void HandleUrl(string url, MetroWindow window)
        {
            url = WebUtility.UrlDecode(url.Remove(0, FullName.Length));

            var r = Regex.Matches(url, "(project|projectGroup)/([^/]*)/([^/]*)/([^/]*)/?");

            foreach (Match m in r)
            {
                var linkType = m.Groups[1].ToString();

                switch (linkType)
                {
                case "project":
                    var gitHubUser     = m.Groups[2].ToString();
                    var repositoryName = m.Groups[3].ToString();
                    var assemblyName   = m.Groups[4].ToString();

                    var w = new InstallerWindow {
                        Owner = window
                    };
                    w.ListAssemblies(
                        string.Format("https://github.com/{0}/{1}", gitHubUser, repositoryName), true,
                        assemblyName != "" ? m.Groups[4].ToString() : null);
                    w.ShowDialog();
                    break;

                case "projectGroup":

                    var remaining  = url.Remove(0, 13);
                    var assemblies = new List <LeagueSharpAssembly>();

                    while (remaining.IndexOf("/", StringComparison.InvariantCulture) != -1)
                    {
                        var data = remaining.Split(new[] { '/' });
                        if (data.Length < 3)
                        {
                            break;
                        }

                        var assembly = new LeagueSharpAssembly(data[2], "",
                                                               string.Format("https://github.com/{0}/{1}", data[0], data[1]));
                        assemblies.Add(assembly);
                        for (int i = 0; i < 3; i++)
                        {
                            remaining = remaining.Remove(0, remaining.IndexOf("/", StringComparison.InvariantCulture) + 1);
                        }
                    }

                    if (assemblies.Count > 0)
                    {
                        assemblies.ForEach(
                            assembly => Config.Instance.SelectedProfile.InstalledAssemblies.Add(assembly));
                        ((MainWindow)window).PrepareAssemblies(assemblies, true, true, false);
                        ((MainWindow)window).ShowTextMessage(Utility.GetMultiLanguageText("Installer"),
                                                             Utility.GetMultiLanguageText("SuccessfullyInstalled"));
                    }
                    break;
                }
            }
        }
        public static void HandleUrl(string url, MetroWindow window)
        {
            url = WebUtility.UrlDecode(url.Remove(0, FullName.Length));

            var r = Regex.Matches(url, "(project|projectGroup)/([^/]*)/([^/]*)/([^/]*)/?");
            foreach (Match m in r)
            {
                var linkType = m.Groups[1].ToString();
              
                switch (linkType)
                {
                    case "project":
                        var gitHubUser = m.Groups[2].ToString();
                        var repositoryName = m.Groups[3].ToString();
                        var assemblyName = m.Groups[4].ToString();

                        var w = new InstallerWindow { Owner = window };
                        w.ListAssemblies(
                            string.Format("https://github.com/{0}/{1}", gitHubUser, repositoryName), true,
                            assemblyName != "" ? m.Groups[4].ToString() : null);
                        w.ShowDialog();
                        break;

                    case "projectGroup":
                        
                        var remaining = url.Remove(0, 13);
                        var assemblies = new List<LeagueSharpAssembly>();

                        while (remaining.IndexOf("/", StringComparison.InvariantCulture) != -1)
                        {
                            var data = remaining.Split(new[] {'/'});
                            if (data.Length < 3)
                            {
                                break;
                            }
                            
                            var assembly = new LeagueSharpAssembly(data[2], "", 
                                string.Format("https://github.com/{0}/{1}", data[0], data[1]));
                            assemblies.Add(assembly);
                            for (int i = 0; i < 3; i++)
                            {
                                remaining = remaining.Remove(0, remaining.IndexOf("/", StringComparison.InvariantCulture) + 1);
                            }
                        }

                        if (assemblies.Count > 0)
                        {
                            assemblies.ForEach(
                                assembly => Config.Instance.SelectedProfile.InstalledAssemblies.Add(assembly));
                            ((MainWindow) window).PrepareAssemblies(assemblies, true, true, false);
                            ((MainWindow) window).ShowTextMessage(Utility.GetMultiLanguageText("Installer"),
                                Utility.GetMultiLanguageText("SuccessfullyInstalled"));
                        }
                        break;
                }
            }
        }
Example #4
0
        public async Task <bool> InstallAsync()
        {
            try
            {
                await InstallerWindow.InstallAssembly(this.AssemblyEntry, true);

                // await Application.Current.Dispatcher.InvokeAsync(() => InstallerWindow.InstallAssembly(this.AssemblyEntry, true));
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Example #5
0
        public static async Task HandleUrl(string url, MetroWindow window)
        {
            url = url.Remove(0, FullName.Length).WebDecode();

            var r = Regex.Matches(url, "(project|projectGroup)/([^/]*)/([^/]*)/([^/]*)/?");

            foreach (Match m in r)
            {
                var linkType = m.Groups[1].ToString();

                switch (linkType)
                {
                case "project":
                    InstallerWindow.InstallAssembly(m);
                    break;
                }
            }
        }
Example #6
0
        protected override void Run()
        {
            WaitForDebugger();

            InitializePackages();

            _BootstrapDispatcher = Dispatcher.CurrentDispatcher;

            // should UI be displayed
            if (Command.Display == Display.Full || Command.Display == Display.Unknown)
            {
                Engine.Log(LogLevel.Verbose, "Launching custom UX");

                _InstallerWindowViewModel = new InstallerWindowViewModel(this);

                InstallerWindow installerWindow = new InstallerWindow
                {
                    DataContext = _InstallerWindowViewModel
                };
                installerWindow.Closed += (s, e) => _BootstrapDispatcher.InvokeShutdown();
                installerWindow.Show();

                Dispatcher.Run();

                Engine.Quit(_ErrorCode);
            }
            else
            {
                DetectComplete  += (sender, args) => Plan(Command.Action);
                PlanComplete    += (sender, args) => Execute();
                ExecuteComplete += (sender, args) =>
                {
                    Engine.Quit(args.Status);
                    _BootstrapDispatcher.InvokeShutdown();
                };

                Detect();

                Dispatcher.Run();
            }
        }
Example #7
0
 // Token: 0x0600038E RID: 910 RVA: 0x00031F4B File Offset: 0x0003014B
 protected override bool __OnCheckCompatibility()
 {
     return(InstallerWindow.ValidateVersion(Globals.MinimumMajorVersion, Globals.MinimumMinorVersion, Globals.ProductTitle, Globals.ProductName, Globals.ProductFeedbackUrl) && base.__OnCheckCompatibility());
 }
Example #8
0
        int executeCommandLine(string[] args, string logPath)
        {
            var animatedGifWindowToken = new CancellationTokenSource();

            using (Disposable.Create(() => animatedGifWindowToken.Cancel())) {
                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 setupIcon         = default(string);
                string icon         = default(string);
                string shortcutArgs = default(string);
                bool   shouldWait   = false;
                bool   noMsi        = (Environment.OSVersion.Platform != PlatformID.Win32NT); // NB: WiX doesn't work under Mono / Wine

                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; target = v; } },
                    { "processStart=", "Start an executable in the latest version of the app package", v => { updateAction = UpdateAction.ProcessStart; processStart = v; }, true },
                    { "processStartHideAndWait=", "Start an executable in the latest version of the app package", v => { updateAction = UpdateAction.ProcessStart; processStart = v; shouldWait = true; }, 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=|icon", "Path to an ICO file that will be used for icon shortcuts", v => icon = v },
                    { "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 },
                    { "no-msi", "Don't generate an MSI package", v => noMsi = true },
                };

                opts.Parse(args);

                // NB: setupIcon and icon are just aliases for compatibility
                // reasons, because of a dumb breaking rename I made in 1.0.1
                setupIcon = setupIcon ?? icon;

                if (updateAction == UpdateAction.Unset)
                {
                    ShowHelp();
                    return(-1);
                }

                switch (updateAction)
                {
#if !MONO
                case UpdateAction.Install:
                {
                    var sourceDirectory = Path.GetFullPath(target) ?? Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                    var releaseEntry    = GetReleaseEntry(sourceDirectory);
                    Func <ProgressSource, Task> installFunc = (progressSource) =>
                                                              Install(silentInstall,
                                                                      progressSource,
                                                                      releaseEntry.PackageName,
                                                                      Path.GetFullPath(target));

                    if (!silentInstall)
                    {
                        InstallerWindow.ShowWindow(releaseEntry.Version.Version,
                                                   new InstallerFactory((progressSource, ct) =>
                            {
                                try
                                {
                                    installFunc(progressSource).Wait(ct);
                                }
                                catch (Exception e)
                                {
                                    this.Log().FatalException("Failed to install", e);
                                    throw;
                                }

                                if (ct.IsCancellationRequested)
                                {
                                    throw new OperationCanceledException("Installation was canceled");
                                }
                            }),
                                                   logPath: logPath).Wait();
                    }
                    else
                    {
                        installFunc(new ProgressSource()).Wait();
                    }

                    break;
                }

                case UpdateAction.Uninstall:
                {
                    var targetLocation  = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                    var sourceDirectory = Path.GetFullPath(Path.Combine(targetLocation, "packages"));
                    var releaseEntry    = GetReleaseEntry(sourceDirectory);
                    Uninstall(releaseEntry.PackageName, targetLocation).Wait();
                    break;
                }

                case UpdateAction.Download:
                    Console.WriteLine(Download(target).Result);
                    break;

                case UpdateAction.Update:
                    Update(target).Wait();
                    break;

                case UpdateAction.UpdateSelf:
                    UpdateSelf().Wait();
                    break;

                case UpdateAction.Shortcut:
                    Shortcut(target, shortcutArgs, processStartArgs, setupIcon);
                    break;

                case UpdateAction.Deshortcut:
                    Deshortcut(target, shortcutArgs);
                    break;

                case UpdateAction.ProcessStart:
                    ProcessStart(processStart, processStartArgs, shouldWait);
                    break;
#endif
                case UpdateAction.Releasify:
                    Releasify(target, releaseDir, packagesDir, bootstrapperExe, backgroundGif, signingParameters, baseUrl, setupIcon, !noMsi);
                    break;
                }
            }

            return(0);
        }