Example #1
0
        public void InstallExtension(string vsixPath)
        {
            if (!Exists())
            {
                throw new InvalidOperationException("Cannot install VSIX in non-existing instance.");
            }

            using (var settings = ExternalSettingsManager.CreateForApplication(GetExePath(), Suffix))
            {
                var ems = new ExtensionManagerService(settings);
                IInstallableExtension vsix = ExtensionManagerService.CreateInstallableExtension(vsixPath);

                if (ems.IsInstalled(vsix))
                {
                    IInstalledExtension installedVsix = ems.GetInstalledExtension(vsix.Header.Identifier);
                    ems.Uninstall(installedVsix);
                    if (ems.IsInstalled(vsix))
                    {
                        throw new InvalidOperationException("Could not uninstall already installed GoogleTestAdapter.");
                    }
                }

                ems.Install(vsix, perMachine: false);
                if (!ems.IsInstalled(vsix))
                {
                    throw new InvalidOperationException("Could not install GoogleTestAdapter.");
                }

                ems.Close();
            }
        }
        internal void InstallExtension(string vsixPath)
        {
            if (!Exists())
                throw new InvalidOperationException("Cannot install VSIX in non-existing instance.");

            using (var settings = ExternalSettingsManager.CreateForApplication(GetExePath(), Suffix))
            {
                var ems = new ExtensionManagerService(settings);
                IInstallableExtension vsix = ExtensionManagerService.CreateInstallableExtension(vsixPath);

                if (ems.IsInstalled(vsix))
                {
                    IInstalledExtension installedVsix = ems.GetInstalledExtension(vsix.Header.Identifier);
                    ems.Uninstall(installedVsix);
                    if (ems.IsInstalled(vsix))
                        throw new InvalidOperationException("Could not uninstall already installed GoogleTestAdapter.");
                }

                ems.Install(vsix, perMachine: false);
                if (!ems.IsInstalled(vsix))
                    throw new InvalidOperationException("Could not install GoogleTestAdapter.");

                ems.Close();
            }
        }
Example #3
0
        private static void RevertUninstall(ExtensionManagerService extensionManager, IInstalledExtension oldExtension)
        {
            if (oldExtension == null || extensionManager.IsInstalled(oldExtension))
            {
                return;
            }

            Log($"Reverting uninstall of '{oldExtension.Header.Name}'...");
            extensionManager.RevertUninstall(oldExtension);
        }