示例#1
0
        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);
            }
        }
示例#2
0
文件: Program.cs 项目: Crae/rhiexec
        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);
        }