Ejemplo n.º 1
0
        /// <summary>
        /// Install package
        /// </summary>
        /// <param name="pkgId"></param>
        public static JsonResponse InstallPackage(string pkgId)
        {
            try
            {
                var packageManager = new NuGet.PackageManager(
                    _repository,
                    new DefaultPackagePathResolver(_feedUrl),
                    new PhysicalFileSystem(HttpContext.Current.Server.MapPath(Utils.ApplicationRelativeWebRoot + "App_Data/packages"))
                    );

                var package = _repository.FindPackage(pkgId);

                packageManager.InstallPackage(package, false);

                FileSystem.CopyPackageFiles(package.Id, package.Version.ToString());

                // reset cache
                Blog.CurrentInstance.Cache.Remove("Installed-Themes");
            }
            catch (Exception ex)
            {
                Utils.Log("PackageManager.InstallPackage", ex);
                return(new JsonResponse {
                    Success = false, Message = "Error installing package, see logs for details"
                });
            }

            return(new JsonResponse {
                Success = true, Message = "Package successfully installed"
            });
        }