private void UpdateForm_Shown(object sender, EventArgs e) { var updater = new PackageUpdater(this, _pendingUpdates); updater.ProgressChanged += (s, ea) => UpdateProgress(ea.Progress, ea.CurrentStep, ea.TotalSteps); updater.Completed += (s, ea) => CompleteUpdate(ea.Exception); updater.Start(); }
private void ProcessRuntimeUpdate() { // A runtime update is requested by adding /RuntimeUpdate to // the arguments. The command line service knows this and always // checks for this argument. var commandLine = (INiCommandLine)GetService(typeof(INiCommandLine)); bool present; string value; ErrorUtil.ThrowOnFailure(commandLine.GetOption("/RuntimeUpdate", out present, out value)); if (!present) { return; } var pendingUpdateLocation = GetPendingUpdateLocation(); // And we want to copy into the bin folder. string target = Path.Combine(_env.FileSystemRoot, "bin"); // Move the current target directory out of the way. string tempTarget; if (!TryMoveTarget(target, out tempTarget)) { // If we aren't able to move the target out of the way // (i.e. can't take ownership of the directory), we can't // continue. We got here in the first place because of a // pending update to NetIde.Package.Core, so we cancel // this and just restart. PackageUpdater.CancelCorePackageUpdate(_env); } else { try { CopyDirectory(pendingUpdateLocation, target); // The restart will take care of removing the pending update // location. } finally { // And finally, remove the temporary target directory because // this is of no use anymore. if (tempTarget != null) { SEH.SinkExceptions(() => Directory.Delete(tempTarget, true)); } } } // We still need to update the NetIde.Package.Core package itself. // Restart the newly installed runtime. string fileName = Path.Combine( target, Path.GetFileName(GetType().Assembly.Location) ); Process.Start(new ProcessStartInfo { FileName = fileName, WorkingDirectory = _env.FileSystemRoot, UseShellExecute = false }); Environment.Exit(0); }