public Task <int> TryExecute(string[] arguments) { var state = _PersistentInstallState.Load(); var serviceName = (string)state[StateConstants.InstalledServiceName].NotNull(); var installer = new WindowsServiceInstaller(new UninstallConfiguration(serviceName)) { Context = _InstallContextProvider.GetContext() }; try { installer.Uninstall(state); } catch { try { installer.Rollback(state); } catch { // Do nothing here } _PersistentInstallState.Delete(); throw; } return(Task.FromResult(0)); }
public Task <int> TryExecute(string[] arguments) { var installer = new WindowsServiceInstaller(_Configuration) { Context = _InstallContextProvider.GetContext() }; var state = new Hashtable { [StateConstants.InstalledServiceName] = _Configuration.ServiceName }; try { installer.Install(state); installer.Commit(state); _PersistentInstallState.Save(state); } catch { try { installer.Rollback(state); } catch { // Do nothing here } throw; } return(Task.FromResult(0)); }