public override RMA.RhiExec.Engine.PackageInstallState GetInstallState(Package package) { // See what version this package contains. PythonPluginInfo ppi = new PythonPluginInfo(); if (!ppi.Initialize(package)) { throw new PackageNotCompatibleException(package.PackagePath); } // Is this installed for All Users? ReportProgress("Getting InstallState for " + this.PackagePath, LogLevel.Debug); // Is plug-in installed for all users? ReportProgress("Checking install state for current user", LogLevel.Debug); string folder = InstallerEngine.InstallRoot(this.InstallRoot); // AllUsersInstallFolder returns ...\plug-in name\version // we want to look in just ...\plug-in name folder = Path.GetDirectoryName(folder); Version InstalledVersion = GetNewestVersionOfInstalledPackage(folder); return(CompareVersions(this.PackageVersion, InstalledVersion)); }
private static void WriteVersionInfoToLog(string[] args) { // Apparently sometimes OSInfo can fail; we'd rather write the log file // and continue installing than have this information. // Fixes http://dev.mcneel.com/bugtrack/?q=68442 try { Logger.Log(LogLevel.Info, string.Format("Start: rhiexec\nversion {0}\n{1}\n{2} {3} {4} {5}", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(), InstallerEngine.Is64BitProcess() ? "64-bit" : "32-bit", OSInfo.Name, OSInfo.Edition, OSInfo.ServicePack, OSInfo.VersionString)); } catch { Logger.Log(LogLevel.Warning, "System information could not be loaded"); } try { StringBuilder msg = new StringBuilder(); msg.Append("arguments: "); foreach (string arg in args) { msg.Append("\r\n\"").Append(arg).Append("\""); } Logger.Log(LogLevel.Info, msg.ToString()); } catch { Logger.Log(LogLevel.Warning, "command line arguments could not be printed"); } Logger.Log(LogLevel.Info, "Logging started: " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture)); }
public override RMA.RhiExec.Engine.PackageInstallState GetInstallState(Package package) { PackageManifest manifestInstalled = new PackageManifest(m_content_type); if (!LoadManifest(this.InstallFolder(InstallerEngine.InstallRoot(this.InstallRoot)), m_content_type, out manifestInstalled)) { return(PackageInstallState.NotInstalled); } PackageManifest manifestNew = new PackageManifest(m_content_type); if (!LoadManifest(PackagePath, m_content_type, out manifestNew)) { throw new ManifestFileNotFoundException(PackagePath); } if (manifestInstalled.VersionNumber > manifestNew.VersionNumber) { return(PackageInstallState.NewerVersionInstalledCurrentUser); } else if (manifestInstalled.VersionNumber == manifestNew.VersionNumber) { return(PackageInstallState.SameVersionInstalledCurrentUser); } else if (manifestInstalled.VersionNumber < manifestNew.VersionNumber) { return(PackageInstallState.OlderVersionInstalledCurrentUser); } else { return(PackageInstallState.NotInstalled); } }
public bool Initialize(Package package) { if (package == null) { InstallerEngine.ReportProgress(LogLevel.Error, "PythonPluginInfo::Initialize called with null package"); return(false); } PackageFileKey plugin_py_key = package.FindSingleFile("__plugin__.py"); string plugin_py = package.GetFullPath(plugin_py_key); if (plugin_py == null) { return(false); } if (!LoadPluginPyFile(plugin_py)) { return(false); } ReadCommandsFromPackage(package); InstallerEngine.ReportProgress(LogLevel.Info, "PythonPluginInfo::Initialize failed"); return(this.IsValid()); }
private void InstallerDialog_Shown(object sender, EventArgs e) { try { InstallerEngine.StartEngine(this); } catch (Exception ex) { ShowErrorDialog(ex); Logger.Log(LogLevel.Error, ex); } }
private void btnNext_Click(object sender, EventArgs e) { DebugLog("Next Button Clicked"); if (InstallerEngine.CurrentPhase() == InstallerPhase.Initialized) { InstallerEngine.InstallAsync(); } else { InstallerEngine.EndInstallation(); } }
private void InstallerDialog_FormClosing(object sender, FormClosingEventArgs e) { if (InstallerEngine.CurrentPhase() == InstallerPhase.Complete || InstallerEngine.CurrentPhase() == InstallerPhase.Success) { // Do nothing; everything finished successfully. } else { DebugLog("InstallerDialog_FormClosing starting"); InstallerEngine.CancelInstallation(); DebugLog("InstallerDialog_FormClosing ending"); } }
public void ShowCompleteDialog() { if (Program.m_options.SilentInstall) { InstallerEngine.EndInstallation(); } else { DebugLog("ShowCompleteDialog starting"); PanelComplete panel = new PanelComplete(); ShowPanel(panel); DebugLog("ShowCompleteDialog ending"); } }
public void ShowWelcomeDialog() { if (Program.m_options.SilentInstall) { InstallerEngine.InstallAsync(); } else { DebugLog("ShowWelcomeDialog starting"); PanelWelcome panel = new PanelWelcome(); panel.SetTitle(InstallerEngine.PackageTitle); ShowPanel(panel); DebugLog("ShowWelcomeDialog ending"); } }
public void ShowAlreadyInstalledDialog() { if (Program.m_options.SilentInstall) { InstallerEngine.EndInstallation(); } else { DebugLog("ShowAlreadyInstalledDialog starting"); PanelMessage panel = new PanelMessage(); panel.SetMessage("This package is already installed."); ShowPanel(panel); DebugLog("ShowAlreadyInstalledDialog ending"); } }
public void ShowErrorDialog(string message) { Logger.Log(LogLevel.Error, message); if (Program.m_options.SilentInstall) { InstallerEngine.EndInstallation(); } else { DebugLog("ShowErrorDialog starting"); PanelMessage panel = new PanelMessage(); panel.SetMessage(message); ShowPanel(panel); DebugLog("ShowErrorDialog ending"); } }
public override bool BeforeInstall(Package package, RhinoInfo[] RhinoList, InstallerUser installAsUser) { // Delete tutorials from roaming profile, if they exist. string RoamingProfileTutorialFolder = InstallerEngine.InstallRoot(PackageInstallRoot.CurrentUserRoamingProfile); RoamingProfileTutorialFolder = Path.Combine(RoamingProfileTutorialFolder, "Tutorials"); if (Directory.Exists(RoamingProfileTutorialFolder)) { try { Directory.Delete(RoamingProfileTutorialFolder, true); } // ReSharper disable EmptyGeneralCatchClause catch // ReSharper restore EmptyGeneralCatchClause { // We don't care if the delete doesn't succeed. } } return(true); }
private static void DebugLog(string msg) { InstallerEngine.DebugLog(msg); }
private void btnCancel_Click(object sender, EventArgs e) { DebugLog("Cancel Button Clicked"); InstallerEngine.CancelInstallation(); }
static int Main(string[] args) { //#if DEBUG // StringBuilder sb = new StringBuilder(); // foreach (string s in args) // sb.Append(s).Append("\n"); // MessageBox.Show("Attach Debugger\n\n"+sb.ToString()); //#endif // Initialize Logger string logfile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); logfile = Path.Combine(logfile, @"McNeel\Rhinoceros\5.0\logs\RhinoInstallerLog.log"); InstallerPhase returnCode = InstallerPhase.Unknown; Logger.LogFile = logfile; Logger.SetLogLevel(LogLevel.Debug); try { m_options.SetOptions(args); Logger.LogFile = m_options.LogFilePath; Logger.SetLogLevel(m_options.LogLevel); WriteVersionInfoToLog(args); while (true) { if (m_options.InspectRhinoPath != null) { returnCode = RhinoInfo.InspectRhinoAndWriteXml(m_options.InspectRhinoPath, m_options.InspectWorkingDirectory); break; } if (m_options.InspectPluginPath != null) { returnCode = PackageInstallerPlugin.InspectPlugin(m_options.InspectPluginPath); break; } if (m_options.Locale != null) { Rhino.UI.Localization.SetLanguageId(m_options.Locale.LCID); } if (m_options.InstallPackagesForRhino) { RhinoInitializer init = new RhinoInitializer(m_options.Locale, m_options.RhinoSdkVersionNumber); init.SetPackageFolder(m_options.PackageFolder); returnCode = (InstallerPhase)init.InstallPackages(); break; } // At this point, we're going to actually execute an .rhi file. // Make sure we have one to execute, lest we throw an exception later. if (string.IsNullOrEmpty(m_options.InstallerFile)) { Logger.Log(LogLevel.Error, "Package not specified on command line."); returnCode = InstallerPhase.PackageNotSpecified; break; } if (!File.Exists(m_options.InstallerFile)) { Logger.Log(LogLevel.Error, string.Format("Package not found: '{0}'", m_options.InstallerFile)); returnCode = InstallerPhase.PackageNotFound; break; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //var fake = new InitializingRhinoDialog(); //fake.ShowDialog(); m_dlg = new InstallerDialog(); if (m_options.SilentInstall) { m_dlg.ShowInTaskbar = false; m_dlg.Size = new System.Drawing.Size(0, 0); m_dlg.StartPosition = FormStartPosition.Manual; m_dlg.Location = new System.Drawing.Point(-5000, -5000); } else { m_dlg.StartPosition = FormStartPosition.CenterScreen; } Application.Run(m_dlg); returnCode = InstallerEngine.CurrentPhase(); break; } } catch (PackageNotCompatibleException ex) { Logger.Log(LogLevel.Error, ex); returnCode = InstallerPhase.InspctPkgNotCompatible; } catch (Exception ex) { Logger.Log(LogLevel.Error, ex); returnCode = InstallerPhase.Exception; } Logger.Log(LogLevel.Debug, string.Format("FinalExit\tExiting installation with return code {0}", returnCode)); WriteFooterToLog(); switch (returnCode) { case InstallerPhase.Success: case InstallerPhase.AlreadyInstalled: case InstallerPhase.AlreadyRunning: case InstallerPhase.PackageNotSpecified: break; default: #if !DEBUG UploadErrorReport(); #endif break; } return((int)returnCode); }
private RegistryKey OpenPluginKey(RegistryKey RegRoot) { if (this.RhinoVersion.Major == 4 && this.RhinoVersion.Minor == 0) { if (InstallerEngine.Is64BitProcess()) { // Installer running in 64-bit process if (this.OS == OSPlatform.x86) { if (RegRoot == Registry.LocalMachine) { return(RegRoot.CreateSubKey(string.Format(CultureInfo.InvariantCulture, @"Software\Wow6432Node\McNeel\Rhinoceros\4.0\{0}\Plug-ins", this.BuildDate))); } else { return(RegRoot.CreateSubKey(string.Format(CultureInfo.InvariantCulture, @"Software\McNeel\Rhinoceros\4.0\{0}\Plug-ins", this.BuildDate))); } } } else { // Installer running in 32-bit process if (this.OS == OSPlatform.x86) { return(RegRoot.CreateSubKey(string.Format(CultureInfo.InvariantCulture, @"Software\McNeel\Rhinoceros\4.0\{0}\Plug-ins", this.BuildDate))); } } throw new UnsupportedPlatformException(this.OS.ToString()); } else if (this.RhinoVersion.Major == 5) { if (InstallerEngine.Is64BitProcess()) { // Installer running in 64-bit process if (this.OS == OSPlatform.x86) { if (RegRoot == Registry.LocalMachine) { return(RegRoot.CreateSubKey(@"Software\Wow6432Node\McNeel\Rhinoceros\5.0\Plug-ins")); } else { return(RegRoot.CreateSubKey(@"Software\McNeel\Rhinoceros\5.0\Plug-ins")); } } else if (this.OS == OSPlatform.x64) { return(RegRoot.CreateSubKey(@"Software\McNeel\Rhinoceros\5.0x64\Plug-ins")); } } else { // Installer running in 32-bit process if (this.OS == OSPlatform.x86) { return(RegRoot.CreateSubKey(@"Software\McNeel\Rhinoceros\5.0\Plug-ins")); } } throw new UnsupportedPlatformException(this.OS.ToString()); } else { throw new RhinoVersionNotSupportedException("OpenCurrentUserPluginKey doesn't support Rhino version " + RhinoVersion); } }
/// <summary> /// Derived classes can (and should) report their progress throughout. /// This method provides thread-safe and thread-agnostic access to the /// main logging engine. /// </summary> /// <param name="message">The message to log</param> /// <param name="level">Log Level</param> public static void ReportProgress(string message, LogLevel level) { InstallerEngine.ReportProgress(level, message); }