public override PackageInstallState GetInstallState(Package package) { PackageInstallState accumulated_state = PackageInstallState.NotInstalled; foreach (PluginInfo pii in m_plugin_lookup.Values) { pii.InstallState = GetPluginInstallState(pii); if (pii.InstallState > accumulated_state) { accumulated_state = pii.InstallState; } pii.WriteXml(); } return(accumulated_state); }
public virtual PackageInstallState GetPackageInstallState(Version VersionNumber) { ReportProgress("Getting Package InstallState for " + this.PackagePath, LogLevel.Debug); // Is plug-in installed for all users? ReportProgress("Checking install state for all users", LogLevel.Debug); string folder = InstallFolder(InstallerEngine.AllUsersInstallRoot); // AllUsersInstallFolder returns ...\plug-in name\version // we want to look in just ...\plug-in name folder = Path.GetDirectoryName(folder); Version InstalledVersion = GetNewestVersionOfInstalledPackage(folder); PackageInstallState state = CompareVersions(VersionNumber, InstalledVersion); if (state > PackageInstallState.NotInstalled) { return(state); } // Is plug-in installed for current user? ReportProgress("Checking install state for current user", LogLevel.Debug); if (this.InstallRoot == PackageInstallRoot.CurrentUserLocalProfile) { folder = InstallFolder(InstallerEngine.CurrentUserLocalProfileRoot); } else if (this.InstallRoot == PackageInstallRoot.CurrentUserRoamingProfile) { folder = InstallFolder(InstallerEngine.CurrentUserRoamingProfileRoot); } // CurrentUserInstallFolder returns ...\plug-in name\version // we want to look in just ...\plug-in name folder = Path.GetDirectoryName(folder); InstalledVersion = GetNewestVersionOfInstalledPackage(folder); return(CompareVersions(VersionNumber, InstalledVersion)); }
/// <summary> /// Init is called to initialize the package for installation. /// No installation is done, only inspection of the package contents. /// /// 1) Extract .rhi package into temp folder /// 2) Select appropriate PackageInstaller /// 3) Initialize PackageInstaller /// 4) Determine if Package is already installed /// 5) Detect Rhino installations /// 6) Is package compatible with any Rhino installations? /// 7) If all above succeeds, Init succeeded. /// /// All logic for inspection and initialization should be in /// the Package code; not the Engine (the Engine should know /// nothing about installing a specific package). /// </summary> /// <param name="InstallerFilePath"></param> static void Init(string PackagePath) { ReportProgress(LogLevel.Info, InstallerPhase.Initializing, "INIT START: " + m_state.InstallerFilePath); if (!File.Exists(PackagePath)) { ReportProgress(LogLevel.Error, InstallerPhase.InitializationFailed, "Installer Package not Found: '" + PackagePath + "'"); return; } m_package = new Package(PackagePath); m_state.TemporaryFolder = CreateTempFolder(); m_package.DestinationFolder = m_state.TemporaryFolder; if (m_init_thread.CancellationPending) { return; } // 2) Select appropriate PackageInstaller ReportProgress(LogLevel.Info, InstallerPhase.Initializing, "Selecting PackageInstaller"); for (int i = 0; i < m_package_installers.Count; i++) { if (m_package_installers[i].ContainsRecognizedPayload(m_package)) { m_selected_installer_index = i; break; } } if (m_init_thread.CancellationPending) { return; } // No appropriate PackageInstaller found if (SelectedInstaller == null) { ReportProgress(LogLevel.Info, InstallerPhase.InitializationFailed, "Initialization Failed - Appropriate Package Installer Not Found"); return; } // 3) Initialize PackageInstaller ReportProgress(LogLevel.Info, InstallerPhase.Initializing, "Initializing PackageInstaller"); SelectedInstaller.Initialize(m_package); if (m_init_thread.CancellationPending) { return; } // 4) Determine if Package is already installed PackageInstallState install_state = SelectedInstaller.GetInstallState(m_package); if (install_state >= PackageInstallState.SameVersionInstalledCurrentUser) { ReportProgress(LogLevel.Info, InstallerPhase.AlreadyInstalled, "Initialization Complete"); return; } // 5) Detect Rhino installations ReportProgress(LogLevel.Info, InstallerPhase.Initializing, "Detecting Rhino"); DetectInstalledRhino(); if (m_init_thread.CancellationPending) { return; } // 6) Is package compatible with any Rhino installations? foreach (RhinoInfo rhino in m_state.RhinoList) { if (SelectedInstaller.IsCompatible(rhino)) { ReportProgress(LogLevel.Info, InstallerPhase.Initializing, "Found Compatible Rhino"); m_state.CompatibleRhinoIsInstalled = RhinoInstallState.Found; break; } if (m_init_thread.CancellationPending) { return; } } if (m_state.CompatibleRhinoIsInstalled == RhinoInstallState.Found) { ReportProgress(LogLevel.Info, InstallerPhase.Initialized, "Initialization Complete"); } else { ReportProgress(LogLevel.Info, InstallerPhase.InspctPkgNotCompatible, "Initialization Failed - This package is not compatible with any of the Rhino installations on this computer."); } }