コード例 #1
0
 public WindowsUpgradeOrchestrator(
     ProductUpgrader upgrader,
     ITracer tracer,
     PhysicalFileSystem fileSystem,
     InstallerPreRunChecker preRunChecker,
     TextReader input,
     TextWriter output)
     : base(upgrader, tracer, fileSystem, preRunChecker, input, output)
 {
 }
コード例 #2
0
        public UpgradeOrchestrator()
        {
            // CommandLine's Parser will create multiple instances of UpgradeOrchestrator, and we don't want
            // multiple log files to get created.  Defer tracer (and preRunChecker) creation until Execute()
            this.tracer        = null;
            this.preRunChecker = null;

            this.fileSystem     = new PhysicalFileSystem();
            this.output         = Console.Out;
            this.input          = Console.In;
            this.ExitCode       = ReturnCode.Success;
            this.installationId = DateTime.Now.ToString("yyyyMMdd_HHmmss");
        }
コード例 #3
0
 public UpgradeOrchestrator(
     ProductUpgrader upgrader,
     ITracer tracer,
     PhysicalFileSystem fileSystem,
     InstallerPreRunChecker preRunChecker,
     TextReader input,
     TextWriter output)
 {
     this.upgrader       = upgrader;
     this.tracer         = tracer;
     this.fileSystem     = fileSystem;
     this.preRunChecker  = preRunChecker;
     this.output         = output;
     this.input          = input;
     this.ExitCode       = ReturnCode.Success;
     this.installationId = DateTime.Now.ToString("yyyyMMdd_HHmmss");
 }
コード例 #4
0
        public void Execute()
        {
            string  error      = null;
            Version newVersion = null;

            if (this.tracer == null)
            {
                this.tracer = this.CreateTracer();
            }

            if (this.preRunChecker == null)
            {
                this.preRunChecker = new InstallerPreRunChecker(this.tracer, ScalarConstants.UpgradeVerbMessages.ScalarUpgradeConfirm);
            }

            try
            {
                if (this.TryInitialize(out error))
                {
                    try
                    {
                        if (!this.TryRunUpgrade(out newVersion, out error))
                        {
                            this.ExitCode = ReturnCode.GenericError;
                        }
                    }
                    finally
                    {
                        this.DeletedDownloadedAssets();
                    }
                }
                else
                {
                    this.ExitCode = ReturnCode.GenericError;
                }

                if (this.ExitCode == ReturnCode.GenericError)
                {
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine();
                    sb.Append("ERROR: " + error);

                    sb.AppendLine();
                    sb.AppendLine();

                    sb.AppendLine($"Upgrade logs can be found at: {this.logDirectory} with file names that end with the installation ID: {this.installationId}.");

                    this.output.WriteLine(sb.ToString());
                }
                else
                {
                    if (newVersion != null)
                    {
                        this.output.WriteLine($"{Environment.NewLine}Upgrade completed successfully.");
                    }
                }
            }
            finally
            {
                this.upgrader?.Dispose();
            }

            if (this.input == Console.In)
            {
                this.output.WriteLine("Press Enter to exit.");
                this.input.ReadLine();
            }

            Environment.ExitCode = (int)this.ExitCode;
        }