Beispiel #1
0
            /// <summary>
            /// Displays error message and exits the installer application.
            /// </summary>
            /// <param name="userFriendlyMessage">User friendly message.</param>
            /// <param name="detailedMessage">Detailed error message.</param>
            /// <param name="logFilePath">Log file path.</param>
            /// <param name="uiMode">Indicates whether installer is running in UI mode or not.</param>
            public static void ShowErrorAndExit(string userFriendlyMessage, string detailedMessage, string logFilePath, bool uiMode)
            {
                InstallerDiagnostics.WriteToEventLog(string.Format(CultureInfo.CurrentCulture, "Please look up execution logs at: {0}", logFilePath));
                InstallerDiagnostics.WriteToEventLog(detailedMessage);
                InstallerDiagnostics.WriteMessageToFile(logFilePath, userFriendlyMessage);
                InstallerDiagnostics.WriteMessageToFile(logFilePath, detailedMessage);

                if (!string.IsNullOrEmpty(userFriendlyMessage) && uiMode)
                {
                    MessageBox.Show(userFriendlyMessage);
                }

                Environment.Exit(1);
            }
Beispiel #2
0
            private static void Execute(string[] args, Assembly assembly)
            {
                string extractionDirectoryPath = Utilities.GetResourceExtractionDirectoryPath(assembly);
                string logFilePath             = InstallerDiagnostics.GetExeLogFilePath(extractionDirectoryPath, assembly);

                progressMessageLogger = (string message) => InstallerDiagnostics.LogProgressMessage(message, logFilePath);

                uiMode = GetUImode(args);
                AppDomain.CurrentDomain.UnhandledException +=
                    (object sender, UnhandledExceptionEventArgs e) => ErrorHandler.CurrentDomain_UnhandledException(logFilePath, e, uiMode);

                InstallerDiagnostics.CreateSelfServiceEventSource();
                Utilities.ValidateNoProcessWithSameNameIsRunning(Process.GetCurrentProcess(), logFilePath, uiMode);

                ContentExtractor contentExtractor = new ContentExtractor(assembly, AssemblyRootNamespace, extractionDirectoryPath);

                UIHelper.ShowMainView(uiMode);

                InstallerDiagnostics.LogProgressMessage(Messages.ProgressMessageUnpackingResources, logFilePath);
                contentExtractor.UnpackResources();

                InstallerDiagnostics.LogProgressMessage(Messages.ProgressMessageValidatingNet45Installed, logFilePath);
                Utilities.ValidateNet45prereq(logFilePath, uiMode);

                InstallerDiagnostics.LogProgressMessage(Messages.ProgressMessageUnpackingContent, logFilePath);
                contentExtractor.UnzipContent();

                UIHelper.HideMainView();

                args = GetUpdatedArgsForSetup(args, contentExtractor, assembly);

                InstallerDiagnostics.LogProgressMessage(Messages.ProgressMessageRunningMainSetupApp, logFilePath);
                Utilities.RunProcessAsyncAndExitWhenCompleted(contentExtractor.GetSetupExePath(), args);

                // We need this to begin running a standard application message loop on the main thread.
                // So that main thread does not exit and waits until setup run finishes.
                Application application = new Application();

                application.Run();
            }
Beispiel #3
0
 /// <summary>
 /// Logs the message to file.
 /// </summary>
 /// <param name="message">Message to log.</param>
 /// <param name="logFilePath">Path to log file.</param>
 public static void LogProgressMessage(string message, string logFilePath)
 {
     InstallerDiagnostics.WriteMessageToFile(logFilePath, message);
 }