private void ChangePackage(CommandEventArgs e, string packageId, string version) { IEnumerable <string> errors = Enumerable.Empty <string>(); switch (e.CommandName.ToLower()) { case "uninstall": { var package = NuGetService.SourceRepository.FindPackage(packageId, (version != null) ? SemanticVersion.Parse(version) : null, false, false); errors = NuGetService.UninstallPackage(package, true); } break; case "install": { var package = NuGetService.SourceRepository.FindPackage(packageId, (version != null) ? SemanticVersion.Parse(version) : null, false, false); if (package != null) { errors = NuGetService.InstallPackage(package); //IEnumerable<IPackage> packagesRequiringLicenseAcceptance = NuGetService.GetPackagesRequiringLicenseAcceptance(package); } break; } case "update": { var installed = NuGetService.GetInstalledPackage(packageId); try { var update = NuGetService.GetUpdate(installed); errors = NuGetService.UpdatePackage(update); } catch (InvalidOperationException ex) { errors.Concat(new[] { string.Format("There is a problem with {0}: {1}", installed.Title, ex.Message) }); } } break; } if (errors != null && errors.Count() > 0) { nbMessage.Visible = true; nbMessage.Text = errors.Aggregate(new StringBuilder("<ul>"), (sb, s) => sb.AppendFormat("<li>{0}</li>", s)).Append("</ul>").ToString(); } }