public static ActionResult InstallService(Session session) { return(session.HandleErrors( () => { // Debugger.Launch(); var filePath = session.Property(InstallBuilder.CustomParam); if (string.IsNullOrEmpty(filePath)) { throw new InvalidOperationException("FilePath is empty"); } if (!File.Exists(filePath)) { throw new InvalidOperationException(filePath + " does not exist"); } var externalTool = new ExternalTool { ExePath = filePath, Arguments = "install" }; session.Log($"Executing '{filePath} install'..."); externalTool.WinRun(); externalTool.Arguments = "start"; session.Log($"Executing '{filePath} start'..."); externalTool.WinRun(); })); }
public static ActionResult UninstallService(Session session) { return(session.HandleErrors( () => { // Debugger.Launch(); var installDir = session.Property("INSTALLDIR"); var filePath = session.Property(InstallBuilder.CustomParam); if (string.IsNullOrEmpty(filePath)) { throw new InvalidOperationException("FilePath is empty"); } if (!File.Exists(filePath)) { throw new InvalidOperationException(filePath + " does not exist"); } var externalTool = new ExternalTool { ExePath = filePath, Arguments = "uninstall" }; session.Log($"Executing '{filePath}' uninstall..."); externalTool.WinRun(); session.Log($"Deleting '{installDir}'..."); Directory.Delete(installDir, true); })); }