public void UninstallPackage([NotNull] string fastPackageReference)
        {
            var  requirements = ParseReference(fastPackageReference);
            bool machineWide  = _request.OptionKeys.Contains(MachineWideKey);

            using (var integrationManager = new IntegrationManager(Handler, machineWide))
                integrationManager.RemoveApp(integrationManager.AppList[requirements.InterfaceUri]);
        }
        public void UninstallPackage(string fastPackageReference)
        {
            if (MachineWide && !WindowsUtils.IsAdministrator)
            {
                throw new NotAdminException(Resources.MustBeAdminForMachineWide);
            }

            var requirements = ParseReference(fastPackageReference);

            using var integrationManager = new IntegrationManager(Config, Handler, MachineWide);
            integrationManager.RemoveApp(integrationManager.AppList[requirements.InterfaceUri]);
        }
Example #3
0
        /// <inheritdoc/>
        protected override ExitCode ExecuteHelper()
        {
            try
            {
                IntegrationManager.RemoveApp(IntegrationManager.AppList[InterfaceUri]);
            }
            #region Sanity checks
            catch (KeyNotFoundException ex)
            {
                // Wrap exception since only certain exception types are allowed
                throw new IOException(ex.Message, ex);
            }
            #endregion

            return(ExitCode.OK);
        }
Example #4
0
    /// <inheritdoc/>
    protected override ExitCode ExecuteHelper()
    {
        var appEntry = IntegrationManager.AppList.GetEntry(InterfaceUri);

        if (appEntry == null)
        {
            Log.Warn(string.Format(Resources.AliasNotFound, InterfaceUri));
            return(ExitCode.NoChanges);
        }

        if (appEntry.AccessPoints != null)
        {
            CheckInstallBase();
        }

        foreach (var hook in appEntry.CapabilityLists.CompatibleCapabilities().OfType <RemoveHook>())
        {
            var process = StartRemoveHook(hook);
            if (process == null)
            {
                continue;
            }

            try
            {
                process.WaitForSuccess();
            }
            catch (ExitCodeException ex)
            {
                Log.Info($"Remove process for {InterfaceUri} cancelled by remove hook {hook.ID} with exit code {ex.ExitCode}");
                return((ExitCode)ex.ExitCode);
            }
        }

        IntegrationManager.RemoveApp(appEntry);

        if (ZeroInstallInstance.IsLibraryMode &&
            !ExistingDesktopIntegration() &&
            (!ZeroInstallInstance.IsMachineWide || !ExistingDesktopIntegration(machineWide: true)))
        {
            Log.Info("Last app removed, auto-removing library mode Zero Install instance");
            StartCommandBackground(Self.Name, Self.Remove.Name, "--batch");
        }

        return(ExitCode.OK);
    }
Example #5
0
    public void RemoveApp()
    {
        var target = new FeedTarget(FeedTest.Test1Uri, new Feed {
            Name = "Test"
        });
        var appEntry = _integrationManager.AddApp(target);

        // Inject access point into AppEntry (without running integration)
        using var unapplyFlag = new TemporaryFlagFile("0install-test-flag");
        appEntry.AccessPoints = new AccessPointList {
            Entries = { new MockAccessPoint {
                            UnapplyFlagPath = unapplyFlag
                        } }
        };

        _integrationManager.RemoveApp(appEntry);
        _integrationManager.AppList.Entries.Should().BeEmpty();

        unapplyFlag.Set.Should().BeTrue(because: "Access points should be unapplied when their AppEntry is removed");
        _integrationManager.Invoking(x => x.RemoveApp(appEntry))
        .Should().NotThrow(because: "Allow multiple removals of applications.");
    }
Example #6
0
    /// <inheritdoc/>
    protected override ExitCode ExecuteHelper()
    {
        try
        {
            IntegrationManager.RemoveApp(IntegrationManager.AppList[InterfaceUri]);
        }
        #region Sanity checks
        catch (KeyNotFoundException ex)
        {
            // Wrap exception since only certain exception types are allowed
            throw new IOException(ex.Message, ex);
        }
        #endregion

        if (ZeroInstallInstance.IsLibraryMode &&
            !ExistingDesktopIntegration() &&
            (!ZeroInstallInstance.IsMachineWide || !ExistingDesktopIntegration(machineWide: true)))
        {
            Log.Info("Last app removed, auto-removing library mode Zero Install instance");
            StartCommandBackground(Self.Name, Self.Remove.Name, "--batch");
        }

        return(ExitCode.OK);
    }