public int Run() { try { // Update the log verbosity. _log.Verbosity = _options.Verbosity; // Set the working directory. _environment.WorkingDirectory = GetWorkingDirectory(); _log.Debug("Working directory: {0}", _environment.WorkingDirectory.FullPath); // Install tools. if (_tools.Count > 0) { _log.Verbose("Installing tools..."); foreach (var tool in _tools) { _installer.Install(tool); } } // Initialize the engine and register everything. _engineInitializer.Initialize(_engine, _context, _tasks, _lifetime, _taskLifetime); // Get the command and execute. var command = _commandFactory.GetCommand(_options); var result = command.ExecuteAsync(_engine, _options).GetAwaiter().GetResult(); // Return success. return(result ? 0 : 1); } catch (Exception exception) { ErrorHandler.OutputError(_log, exception); return(ErrorHandler.GetExitCode(exception)); } }
public int Run() { try { // Update the log verbosity and working directory. _log.Verbosity = _options.Verbosity; _environment.WorkingDirectory = _options.WorkingDirectory.MakeAbsolute(_environment); // Initialize the engine and register everything. _engineInitializer.Initialize(_engine, _context, _tasks, _lifetime, _taskLifetime); // Get the command and execute. var command = _commandFactory.GetCommand(_options); var result = command.Execute(_engine, _options); // Return success. return(result ? 0 : 1); } catch (Exception exception) { ErrorHandler.OutputError(_log, exception); return(ErrorHandler.GetExitCode(exception)); } }