示例#1
0
        public async Task UninstallPackageAsync(IPackageDetails package, CancellationToken token = default)
        {
            Argument.IsNotNull(() => package);

            var uninstalledIdentity = package.GetIdentity();
            var uninstallPath       = _defaultProject.GetInstallPath(uninstalledIdentity);

            try
            {
                //nuPackage should provide identity of installed package, which targeted for uninstall action
                _packageOperationNotificationService.NotifyOperationStarting(uninstallPath, PackageOperationType.Uninstall, package);
                await _nuGetPackageManager.UninstallPackageForProjectAsync(_defaultProject, package.GetIdentity(), token);
            }
            catch (Exception ex)
            {
                await _logger.LogAsync(LogLevel.Error, ex.Message);

                _packageOperationContextService.CurrentContext.Exceptions.Add(ex);
            }
            finally
            {
                FinishOperation(PackageOperationType.Uninstall, uninstallPath, package);
            }
        }