public static ActionResult InstallPreset(Session session) { string presetStr = session.CustomActionData["PRESET"]; string appStartMenuPath = session.CustomActionData["APP_START_MENU_PATH"]; string installDir = session.CustomActionData["INSTALLDIR"]; RollbarHelper.ConfigureRollbarSingleton(session.CustomActionData["MSI_VERSION"]); var preset = Preset.ParsePreset.Parse(presetStr, session, installDir, appStartMenuPath); if (preset == null) { session.Log("No valid preset set"); return(ActionResult.Failure); } try { var res = preset.Install(); if (res != ActionResult.Success) { RollbarReport.Error(string.Format("unexpected failure in Preset installation"), session); } return(res); } catch (Exception err) { RollbarReport.Critical(string.Format("unknown error in language preset: {0}", err), session); return(ActionResult.Failure); } }
public static ActionResult InstallStateTool(Session session, out string stateToolPath) { RollbarHelper.ConfigureRollbarSingleton(session.CustomActionData["MSI_VERSION"]); session.Log("Installing State Tool if necessary"); if (session.CustomActionData["STATE_TOOL_INSTALLED"] == "true") { stateToolPath = session.CustomActionData["STATE_TOOL_PATH"]; session.Log("State Tool is installed, no installation required"); Status.ProgressBar.Increment(session, 250); TrackerSingleton.Instance.TrackEventSynchronously(session, "stage", "state-tool", "skipped"); return ActionResult.Success; } Status.ProgressBar.StatusMessage(session, "Installing State Tool..."); Status.ProgressBar.Increment(session, 50); var ret = _installStateTool(session, out stateToolPath); if (ret == ActionResult.Success) { TrackerSingleton.Instance.TrackEventSynchronously(session, "stage", "state-tool", "success"); } else if (ret == ActionResult.Failure) { TrackerSingleton.Instance.TrackEventSynchronously(session, "stage", "state-tool", "failure"); } return ret; }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { RollbarHelper.ConfigureRollbarSingleton(); //START: Let's subscribe to all known unhandled exception events application-wide... RollbarHelper.RegisterForGlobalExceptionHandling(); //END. global::Xamarin.Forms.Forms.Init(); LoadApplication(new App()); return(base.FinishedLaunching(app, options)); }
public static ActionResult Rollback(Session session) { session.Log("Begin rollback of state tool installation and deploy"); RollbarHelper.ConfigureRollbarSingleton(session.CustomActionData["COMMIT_ID"]); RollbackStateToolInstall(session); RollbackDeploy(session); // This custom action should not abort on failure, just report return(ActionResult.Success); }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { // Rollbar notifier configuartion RollbarHelper.ConfigureRollbarSingleton(); // Registers for global exception handling. RollbarHelper.RegisterForGlobalExceptionHandling(); global::Xamarin.Forms.Forms.Init(); LoadApplication(new App(new iOSInitializer())); return(base.FinishedLaunching(app, options)); }
public static ActionResult Rollback(Session session) { var installDir = session.CustomActionData["INSTALLDIR"]; RollbarHelper.ConfigureRollbarSingleton(session.CustomActionData["MSI_VERSION"]); session.Log("Begin rollback of state tool installation and deploy"); RollbackStateToolInstall(session); RollbackDeploy(session); // This custom action should not abort on failure, just report return(ActionResult.Success); }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { RollbarHelper.ConfigureRollbar(); RollbarLocator.RollbarInstance .Info("Xamarin.Forms sample: Hello world! Xamarin is here..."); //START: Let's subscribe to all known unhandled exception events application-wide... RollbarHelper.RegisterForGlobalExceptionHandling(); this.UnhandledException += App_UnhandledException; //END. this.InitializeComponent(); this.Suspending += OnSuspending; }
protected override void OnCreate(Bundle bundle) { RollbarHelper.ConfigureRollbarSingleton(); // First informational log via Rollbar: RollbarLocator.RollbarInstance .Info("Xamarin.Forms sample: Hello world! Xamarin is here @MainActivity.OnCreate(...) ..."); //START: Let's subscribe to all known unhandled exception events application-wide... RollbarHelper.RegisterForGlobalExceptionHandling(); AndroidEnvironment.UnhandledExceptionRaiser += AndroidEnvironment_UnhandledExceptionRaiser; //END. TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); LoadApplication(new App()); }
protected override void OnCreate(Bundle bundle) { // Rollbar notifier configuartion RollbarHelper.ConfigureRollbarSingleton(); // Registers for global exception handling. RollbarHelper.RegisterForGlobalExceptionHandling(); AndroidEnvironment.UnhandledExceptionRaiser += (sender, args) => { var newExc = new ApplicationException("AndroidEnvironment_UnhandledExceptionRaiser", args.Exception); RollbarHelper.RollbarInstance.AsBlockingLogger(TimeSpan.FromSeconds(10)).Critical(newExc); }; TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); LoadApplication(new App(new AndroidInitializer())); }
public static ActionResult InstallStateTool(Session session, out string stateToolPath) { RollbarHelper.ConfigureRollbarSingleton(session.CustomActionData["COMMIT_ID"]); session.Log("Installing State Tool if necessary"); if (session.CustomActionData["STATE_TOOL_INSTALLED"] == "true") { stateToolPath = session.CustomActionData["STATE_TOOL_PATH"]; session.Log("State Tool is installed, no installation required"); Status.ProgressBar.Increment(session, 1); return(ActionResult.Success); } Status.ProgressBar.StatusMessage(session, "Installing State Tool..."); Status.ProgressBar.Increment(session, 1); stateToolPath = ""; var paths = GetPaths(); string stateURL = "https://s3.ca-central-1.amazonaws.com/cli-update/update/state/unstable/"; string jsonURL = stateURL + paths.JsonDescription; string timeStamp = DateTime.Now.ToFileTime().ToString(); string tempDir = Path.Combine(Path.GetTempPath(), timeStamp); session.Log(string.Format("Using temp path: {0}", tempDir)); try { Directory.CreateDirectory(tempDir); } catch (Exception e) { string msg = string.Format("Could not create temp directory at: {0}, encountered exception: {1}", tempDir, e.ToString()); session.Log(msg); RollbarReport.Critical(msg); return(ActionResult.Failure); } ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; string versionInfoString; session.Log(string.Format("Downloading JSON from URL: {0}", jsonURL)); try { WebClient client = new WebClient(); versionInfoString = client.DownloadString(jsonURL); } catch (WebException e) { string msg = string.Format("Encountered exception downloading state tool json info file: {0}", e.ToString()); session.Log(msg); RollbarReport.Critical(msg); return(ActionResult.Failure); } VersionInfo info; try { info = JsonConvert.DeserializeObject <VersionInfo>(versionInfoString); } catch (Exception e) { string msg = string.Format("Could not deserialize version info. Version info string {0}, exception {1}", versionInfoString, e.ToString()); session.Log(msg); RollbarReport.Critical(msg); return(ActionResult.Failure); } string zipPath = Path.Combine(tempDir, paths.ZipFile); string zipURL = stateURL + info.version + "/" + paths.ZipFile; session.Log(string.Format("Downloading zip file from URL: {0}", zipURL)); Status.ProgressBar.StatusMessage(session, "Downloading State Tool..."); try { WebClient client = new WebClient(); client.DownloadFile(zipURL, zipPath); } catch (WebException e) { string msg = string.Format("Encoutered exception downloading state tool zip file. URL to zip file: {0}, path to save zip file to: {1}, exception: {2}", zipURL, zipPath, e.ToString()); session.Log(msg); RollbarReport.Critical(msg); return(ActionResult.Failure); } SHA256 sha = SHA256.Create(); FileStream fInfo = File.OpenRead(zipPath); string zipHash = BitConverter.ToString(sha.ComputeHash(fInfo)).Replace("-", string.Empty).ToLower(); if (zipHash != info.sha256v2) { string msg = string.Format("SHA256 checksum did not match, expected: {0} actual: {1}", info.sha256v2, zipHash.ToString()); session.Log(msg); RollbarReport.Critical(msg); return(ActionResult.Failure); } Status.ProgressBar.StatusMessage(session, "Extracting State Tool executable..."); try { ZipFile.ExtractToDirectory(zipPath, tempDir); } catch (Exception e) { string msg = string.Format("Could not extract State Tool, encountered exception. Path to zip file: {0}, path to temp directory: {1}, exception {2})", zipPath, tempDir, e); session.Log(msg); RollbarReport.Critical(msg); return(ActionResult.Failure); } string stateToolInstallDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ActiveState", "bin"); try { Directory.CreateDirectory(stateToolInstallDir); } catch (Exception e) { string msg = string.Format("Could not create State Tool install directory at: {0}, encountered exception: {1}", stateToolInstallDir, e.ToString()); session.Log(msg); RollbarReport.Critical(msg); return(ActionResult.Failure); } stateToolPath = Path.Combine(stateToolInstallDir, "state.exe"); if (File.Exists(stateToolPath)) { try { File.Delete(stateToolPath); } catch (Exception e) { string msg = string.Format("Could not remove existing temporary state tool executable at: {0}, encountered exception: {1}", stateToolPath, e.ToString()); session.Log(msg); RollbarReport.Critical(msg); return(ActionResult.Failure); } } try { File.Move(Path.Combine(tempDir, paths.ExeFile), stateToolPath); } catch (Exception e) { string msg = string.Format("Could not move State Tool executable to: {0}, encountered exception: {1}", stateToolPath, e); session.Log(msg); RollbarReport.Critical(msg); return(ActionResult.Failure); } string configDirCmd = " export" + " config" + " --filter=dir"; string output; ActionResult runResult = ActiveState.Command.Run(session, stateToolPath, configDirCmd, out output); session.Log("Writing install file..."); // We do not fail the installation if writing the installsource.txt file fails if (runResult.Equals(ActionResult.Failure)) { string msg = string.Format("Could not get config directory from State Tool"); session.Log(msg); RollbarReport.Error(msg); } else { string contents = "msi-ui"; if (session.CustomActionData["UI_LEVEL"] == "2") { contents = "msi-silent"; } try { string installFilePath = Path.Combine(output.Trim(), "installsource.txt"); File.WriteAllText(installFilePath, contents); } catch (Exception e) { string msg = string.Format("Could not write install file at path: {0}, encountered exception: {1}", output, e.ToString()); session.Log(msg); RollbarReport.Error(msg); } } session.Log("Updating PATH environment variable"); string oldPath = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Machine); if (oldPath.Contains(stateToolInstallDir)) { session.Log("State tool installation already on PATH"); return(ActionResult.Success); } var newPath = string.Format("{0};{1}", stateToolInstallDir, oldPath); session.Log(string.Format("updating PATH to {0}", newPath)); try { Environment.SetEnvironmentVariable("PATH", newPath, EnvironmentVariableTarget.Machine); } catch (Exception e) { string msg = string.Format("Could not update PATH. Attempted to set path to: {0}, encountered exception: {1}", newPath, e.ToString()); session.Log(msg); RollbarReport.Critical(msg); return(ActionResult.Failure); } return(ActionResult.Success); }