Exemple #1
0
        private static void revertOldInstallations()
        {
            string defaultInstallLocation = StringUtils.GetDefaultInstallLocation(
                Windows.ApplicationModel.Package.Current.PublisherDisplayName);

            AppFinder.AppInfo appInfo = AppFinder.GetApplicationInfo(new string[] { "mrHelper" });
            if (appInfo != null ||
                Directory.Exists(defaultInstallLocation) ||
                System.IO.File.Exists(StringUtils.GetShortcutFilePath()))
            {
                MessageBox.Show("mrHelper needs to uninstall an old version of itself on this launch. "
                                + "It takes a few seconds, please wait...", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                string           currentPackagePath     = Windows.ApplicationModel.Package.Current.InstalledLocation.Path;
                string           revertMsiProjectFolder = "mrHelper.RevertMSI";
                string           revertMsiProjectName   = "mrHelper.RevertMSI.exe";
                ProcessStartInfo startInfo = new ProcessStartInfo
                {
                    FileName         = System.IO.Path.Combine(currentPackagePath, revertMsiProjectFolder, revertMsiProjectName),
                    WorkingDirectory = System.IO.Path.Combine(currentPackagePath, revertMsiProjectFolder),
                    Verb             = "runas", // revert implies work with registry
                };
                Process p = Process.Start(startInfo);
                p.WaitForExit();
                Trace.TraceInformation(String.Format("{0} exited with code {1}", revertMsiProjectName, p.ExitCode));
            }
        }
Exemple #2
0
        private static void revert()
        {
            AppFinder.AppInfo appInfo = AppFinder.GetApplicationInfo(new string[] { "mrHelper" });
            if (appInfo != null)
            {
                uninstall(appInfo.ProductCode);
            }

            string defaultInstallLocation = StringUtils.GetDefaultInstallLocation(
                Windows.ApplicationModel.Package.Current.PublisherDisplayName);

            cleanupBinaries(appInfo == null ? defaultInstallLocation : appInfo.InstallPath);

            cleanupShortcut(StringUtils.GetShortcutFilePath());

            removeProtocolFromRegistry();
        }
        /// <summary>
        /// Throws DiffToolNotInstalledException if diff tool is not installed
        /// Throws DiffToolIntegrationException if integration failed
        /// </summary>
        public void Integrate(IIntegratedDiffTool diffTool, string self)
        {
            AppFinder.AppInfo appInfo = AppFinder.GetApplicationInfo(diffTool.GetToolRegistryNames());
            if (appInfo == null || !isInstalled(appInfo.InstallPath))
            {
                throw new DiffToolNotInstalledException("Diff tool not installed");
            }

            string toolpath = appInfo.InstallPath;

            Trace.TraceInformation(String.Format("Diff Tool installed at: {0}", toolpath));

            registerInGit(diffTool, toolpath);

            try
            {
                registerInTool(diffTool, self);
            }
            catch (DiffToolIntegrationException)
            {
                Trace.TraceError(String.Format("Cannot register the application in \"{0}\"", Constants.GitDiffToolName));

                try
                {
                    string key = String.Format("difftool.{0}.cmd", Constants.GitDiffToolName);
                    GitTools.SetConfigKeyValue(GitTools.ConfigScope.Global, key, null, String.Empty);
                }
                catch (ExternalProcessSystemException)
                {
                    Trace.TraceError(String.Format("Cannot remove \"{0}\" from git config", Constants.GitDiffToolName));
                }
                catch (ExternalProcessFailureException)
                {
                    Trace.TraceError(String.Format("Cannot remove \"{0}\" from git config", Constants.GitDiffToolName));
                }

                throw;
            }
        }
Exemple #4
0
 private static string getBinaryFilePath()
 {
     AppFinder.AppInfo appInfo = AppFinder.GetApplicationInfo(new string[] { RegistryDisplayName });
     return(appInfo != null && !String.IsNullOrWhiteSpace(appInfo.InstallPath)
     ? Path.Combine(appInfo.InstallPath, BinaryFileName) : null);
 }