private static DotNetNuke.Services.Installer.Installer GetInstaller(Stream stream, string fileName, int portalId, string legacySkin = null)
        {
            var installer = new DotNetNuke.Services.Installer.Installer(stream, ApplicationMapPath, false, false);

            // We always assume we are installing from //Host/Extensions (in the previous releases)
            // This will not work when we try to install a skin/container under a specific portal.
            installer.InstallerInfo.PortalID = Null.NullInteger;
            //Read the manifest
            if (installer.InstallerInfo.ManifestFile != null)
            {
                installer.ReadManifest(true);
            }
            return(installer);
        }
 private static void DeleteTempInstallFiles(DotNetNuke.Services.Installer.Installer installer)
 {
     try
     {
         var tempFolder = installer.TempInstallFolder;
         if (!string.IsNullOrEmpty(tempFolder) && Directory.Exists(tempFolder))
         {
             Globals.DeleteFolderRecursive(tempFolder);
         }
     }
     catch (Exception ex)
     {
         //
     }
 }
        public ConsoleResultModel Run()
        {
            string res = "";

            try
            {
                if (IsPackage)
                {
                    res = InstallPackage(PortalSettings, User, Path);
                }
                else if (IsManifest)
                {
                    DotNetNuke.Services.Installer.Installer installer = new DotNetNuke.Services.Installer.Installer(Path, ApplicationMapPath, true);
                    if (installer.IsValid)
                    {
                        installer.InstallerInfo.Log.Logs.Clear();
                        installer.Install();
                        if (installer.IsValid)
                        {
                            res = string.Format("<strong>Successfully added {0}</strong>", Path);
                            // Return installer.InstallerInfo.PackageID
                        }
                        else
                        {
                            return(new ConsoleErrorResultModel("An error occurred while attempting to add the extension. Please see the DNN Event Viewer for details."));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(new ConsoleErrorResultModel("An error occurred while attempting to add the extension. Please see the DNN Event Viewer for details."));
            }
            return(new ConsoleResultModel(res)
            {
                isHtml = true
            });
        }