Exemple #1
0
        public void Open(string contractName)
        {
            _catalog = AppExtensionCatalog.Open(contractName);

            _catalog.PackageInstalled     += (s, e) => PackageInstalled?.Invoke(this, new AppExtensionPackageInstalledEventArgsWrapper(e));
            _catalog.PackageUpdated       += (s, e) => PackageUpdated?.Invoke(this, new AppExtensionPackageUpdatedEventArgsWrapper(e));
            _catalog.PackageUninstalling  += (s, e) => PackageUninstalling?.Invoke(this, new AppExtensionPackageUninstallingEventArgsWrapper(e));
            _catalog.PackageUpdating      += (s, e) => PackageUpdating?.Invoke(this, new AppExtensionPackageUpdatingEventArgsWrapper(e));
            _catalog.PackageStatusChanged += (s, e) => PackageStatusChanged?.Invoke(this, new AppExtensionPackageStatusChangedEventArgsWrapper(e));
        }
Exemple #2
0
        public async Task UninstallAsync(IEnumerable <NuGetProject> projects, IEnumerable <string> packages, bool removeDependencies, bool forceRemove, bool shouldThrow, CancellationToken token)
        {
            MyProjectContext projectContext = new MyProjectContext(FileConflictAction.OverwriteAll)
            {
                ActionType = NuGetActionType.Uninstall,
                PackageExtractionContext = _packageExtractionContext
            };

            // sort packages
            // packages = SortPackagesWhenUninstallAsync(projects, packages);

            foreach (string packageId in packages)
            {
                var uninstallationContext = new UninstallationContext(removeDependencies, forceRemove);
                IReadOnlyList <ResolvedAction> actions = await GetActionsForUninstallAsync(
                    uninstallationContext : uninstallationContext,
                    targets : projects,
                    packageId : packageId,
                    projectContext : projectContext,
                    token : token);

                if (actions.Count != 0)
                {
                    PackageUninstalling?.Invoke(packageId);

                    try
                    {
                        await ExecuteActionsAsync(actions, null, projectContext, NullSourceCacheContext.Instance, token);
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex);
                        if (shouldThrow)
                        {
                            throw;
                        }
                    }
                    finally
                    {
                        PackageUninstalled?.Invoke(packageId);
                    }
                }
            }
        }
Exemple #3
0
 private void NuGetPackageUninstalling(string packageId)
 {
     PackageUninstalling?.Invoke(packageId);
 }
 public void OnPackageUninstalling(IDotNetProject project, NuGet.ProjectManagement.PackageEventArgs e)
 {
     PackageUninstalling?.Invoke(this, new PackageManagementEventArgs(project, e));
 }