public static UninstallPackage ( string pkgId ) : void | ||
pkgId | string | Package Id |
리턴 | void |
/// <summary> /// Uninstall package /// </summary> /// <param name="pkgId"></param> /// <returns></returns> public static bool UninstallPackage(string pkgId) { try { FileSystem.UninstallPackage(pkgId); Utils.Log(string.Format("Uninstalled package {0}: installed package files removed. ", pkgId)); // remove packagefiles.xml and packages.xml (or DB records) BlogService.DeletePackage(pkgId); Utils.Log(string.Format("Uninstalled package {0}: package records removed. ", pkgId)); UninstallGalleryPackage(pkgId); Utils.Log(string.Format("Uninstalled package {0}: NuGet file removed. ", pkgId)); // reset cache Blog.CurrentInstance.Cache.Remove(Constants.CacheKey); Utils.Log(string.Format("Uninstalled package {0} by {1}", pkgId, Security.CurrentUser.Identity.Name)); } catch (Exception ex) { Utils.Log(string.Format("Error unistalling package {0}: {1}"), pkgId, ex.Message); throw; } return(true); }
/// <summary> /// Uninstall package /// </summary> /// <param name="pkgId"></param> /// <returns></returns> public static JsonResponse UninstallPackage(string pkgId) { try { var packageManager = new PackageManager( _repository, new DefaultPackagePathResolver(BlogSettings.Instance.GalleryFeedUrl), new PhysicalFileSystem(HttpContext.Current.Server.MapPath(Utils.ApplicationRelativeWebRoot + "App_Data/packages")) ); var package = _repository.FindPackage(pkgId); if (package == null) { return new JsonResponse { Success = false, Message = "Package " + pkgId + " not found" } } ; packageManager.UninstallPackage(package, true); FileSystem.UninstallPackage(package.Id); BlogService.DeletePackage(pkgId); // reset cache Blog.CurrentInstance.Cache.Remove(Constants.CacheKey); Utils.Log(string.Format("Uninstalled package {0} by {1}", pkgId, Security.CurrentUser.Identity.Name)); } catch (Exception ex) { Utils.Log("BlogEngine.Core.Packaging.Installer.UninstallPackage(" + pkgId + ")", ex); return(new JsonResponse { Success = false, Message = "Error uninstalling package, see logs for details" }); } return(new JsonResponse { Success = true, Message = "Package successfully uninstalled" }); }