private static void ReportProgress(LogLevel level, InstallerPhase phase, string message, int percentComplete) { // if we're running in the main thread, just call the function. ProgressReport msg = new ProgressReport(); msg.Phase = phase; msg.Level = level; msg.Message = message; int current_thread_id = Thread.CurrentThread.ManagedThreadId; ProgressChangedEventArgs args = new ProgressChangedEventArgs(percentComplete, msg); if (current_thread_id == m_main_thread_id) { m_worker_ProgressChanged(null, args); } else if (m_init_thread.IsBusy) { m_init_thread.ReportProgress(percentComplete, msg); } else if (m_install_thread.IsBusy) { m_install_thread.ReportProgress(percentComplete, msg); } else { throw new RhinoInstallerException("ReportProgress called with unexpected thread context."); } }
static void CleanupAndExit() { if (m_state.ApplicationExiting) { return; } m_state.ApplicationExiting = true; DebugLog("CleanupAndExit starting"); InstallerPhase final_state = InstallerPhase.Complete; if (m_state.CurrentPhase >= InstallerPhase.InitializationFailed) { final_state = m_state.CurrentPhase; } if (m_state.CurrentPhase > InstallerPhase.Complete) { ReportProgress(LogLevel.Info, InstallerPhase.Cleanup, "Cleaning Up"); DeleteTempFolders(); ReportProgress(LogLevel.Info, final_state, "Complete"); } ReportProgress(LogLevel.Info, final_state, "Exiting"); Logger.PurgeOldLogs(); DebugLog("CleanupAndExit ending"); Application.Exit(); }
static void m_worker_InstallComplete(object sender, RunWorkerCompletedEventArgs e) { DebugLog("m_worker_InstallComplete starting"); if (e.Error != null) { ReportProgress(LogLevel.Error, InstallerPhase.InstallFailed, "m_worker_InstallComplete exception caught"); m_state.CurrentPhase = InstallerPhase.InstallFailed; m_user_interface.ShowErrorDialog(e.Error); } if (e.Cancelled) { DebugLog("m_worker_InstallComplete cancelled"); m_state.CurrentPhase = InstallerPhase.Canceled; CleanupAndExit(); } InstallerPhase state = m_state.CurrentPhase; switch (state) { case InstallerPhase.Complete: m_user_interface.ShowCompleteDialog(); break; case InstallerPhase.InstallFailed: m_user_interface.ShowErrorDialog(); break; default: throw new InstallException("InitCompleted encountered unexpected state."); } DebugLog("m_worker_InstallComplete exiting"); }
public override bool Initialize(Package package) { m_package = package; // See if at least one compatible Rhino is installed. Guid last_plugin_id = Guid.Empty; Collection <PackageFileKey> rhp_files = ListRhpFiles(package); bool foundOneValidRhino = false; foreach (PackageFileKey rhp in rhp_files) { string rhp_full_path = package.GetFullPath(rhp); InstallerPhase rc = ExecutePluginInspector(rhp_full_path); if (rc != InstallerPhase.Success) { continue; } foundOneValidRhino = true; PluginInfo pii = new PluginInfo(); pii.PluginPath = rhp_full_path; pii.ReadXml(); m_plugin_lookup.Add(rhp, pii); if (last_plugin_id != Guid.Empty && pii.ID != last_plugin_id) { ReportProgress("Plug-in GUID mismatch: " + pii.ID + " != " + last_plugin_id, LogLevel.Error); throw new GuidMismatchException("All plug-ins in an installer must have the same GUID. Two different GUIDs were found."); } last_plugin_id = pii.ID; } if (!foundOneValidRhino) { ReportProgress("Plug-in inspection failed", LogLevel.Error); throw new PackageNotCompatibleException(package.PackagePath); } m_id = last_plugin_id; return(true); }
static void DetectInstalledRhino() { List <string> InstallPaths = SearchRegistryForRhinoInstallPaths(); foreach (string path in InstallPaths) { ReportProgress(LogLevel.Debug, string.Format("Rhino found here: {0}", path)); } string[] rhino_xml_files = Directory.GetFiles(m_state.TemporaryFolder, "__~~RhinoInfo~~__.*.tmp.xml"); foreach (string rhino_xml_file in rhino_xml_files) { File.Delete(rhino_xml_file); } foreach (string rhpath in InstallPaths) { if (!File.Exists(rhpath)) { // Don't bother spawning an inspection process if rhpath is not found. // Fixes http://dev.mcneel.com/bugtrack/?q=68438 ReportProgress(LogLevel.Info, InstallerPhase.Unknown, "DetectInstalledRhino() cound not find file: " + rhpath); continue; } InstallerPhase rc = Program.ExecuteChildProcess(OSPlatform.x86, "/INSPECTRHINO \"" + rhpath + "\" /INSPECTWORKINGDIR \"" + m_state.TemporaryFolder + "\"", false); if (rc != InstallerPhase.Success) { if (Is64BitProcess()) { Program.ExecuteChildProcess(OSPlatform.x64, "/INSPECTRHINO \"" + rhpath + "\" /INSPECTWORKINGDIR \"" + m_state.TemporaryFolder + "\"", false); } } } string[] rhino_info_files = Directory.GetFiles(m_state.TemporaryFolder, "__~~RhinoInfo~~__*.tmp.xml"); foreach (string rhino_info in rhino_info_files) { RhinoInfo info = new RhinoInfo(); info.ReadXml(Path.Combine(m_state.TemporaryFolder, rhino_info)); m_state.AddRhino(info); } }
private static InstallerPhase ExecutePluginInspector(string PluginPath) { ReportProgress("Executing 32-bit Plug-in Inspector for '" + PluginPath + "'", LogLevel.Debug); InstallerPhase rc = Program.ExecuteChildProcess(OSPlatform.x86, "/INSPECTPLUGIN \"" + PluginPath + "\"", false); switch (rc) { case InstallerPhase.Success: case InstallerPhase.InspctPkgNotCompatible: break; default: if (IntPtr.Size == 8) { ReportProgress("Executing 64-bit Plug-in Inspector for '" + PluginPath + "'", LogLevel.Debug); rc = Program.ExecuteChildProcess(OSPlatform.x64, "/INSPECTPLUGIN \"" + PluginPath + "\"", false); } break; } return(rc); }
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); }
public void DoInstallPackages() { Program.m_options.SilentInstall = true; // Find the directory with packages to install. if (string.IsNullOrEmpty(m_package_folder)) { throw new Model.RhinoInstallerException("Need to detect location of packages folder"); } List <string> packages_to_install = new List <string>(); // Updated format again to have 'en-us' instead of 'en' string localization_pattern = string.Format(CultureInfo.InvariantCulture, "*({0}).rhi", m_culture.Name); packages_to_install.AddRange(Directory.GetFiles(m_package_folder, localization_pattern)); // Packages for all languages string all_languages_pattern = string.Format(CultureInfo.InvariantCulture, "*(any).rhi"); packages_to_install.AddRange(Directory.GetFiles(m_package_folder, all_languages_pattern)); InstallerPhase result = InstallerPhase.Unknown; bool bInstallFailed = false; // Install "UI*" first for (int i = packages_to_install.Count - 1; i >= 0; i--) { string pkgName = Path.GetFileName(packages_to_install[i]); if (string.IsNullOrEmpty(pkgName)) { continue; } pkgName = pkgName.ToUpperInvariant(); if (pkgName.StartsWith("UI")) { result = InstallPackage(packages_to_install[i]); if (result != InstallerPhase.Success && result != InstallerPhase.AlreadyInstalled) { bInstallFailed = true; } packages_to_install.RemoveAt(i); } } // Install "localiation*" second for (int i = packages_to_install.Count - 1; i >= 0; i--) { string pkgName = Path.GetFileName(packages_to_install[i]); if (string.IsNullOrEmpty(pkgName)) { continue; } pkgName = pkgName.ToUpperInvariant(); if (pkgName.StartsWith("LOCALIZATION")) { result = InstallPackage(packages_to_install[i]); if (result != InstallerPhase.Success && result != InstallerPhase.AlreadyInstalled) { bInstallFailed = true; } packages_to_install.RemoveAt(i); } } // Run the rest of the packages next. foreach (string package in packages_to_install) { result = InstallPackage(package); if (result != InstallerPhase.Success && result != InstallerPhase.AlreadyInstalled) { bInstallFailed = true; } } // Done! if (!bInstallFailed) { SavePackageSdkServiceRelease_Registry(); } }
private static void ReportProgress(LogLevel level, InstallerPhase phase, string message) { ReportProgress(level, phase, message, 0); }