protected override int DoExecute(ITaskContextInternal context) { IRunProgramTask task = context .Tasks() .RunProgramTask("systemctl") .WithArguments(_command, _service); if (DoNotFail) { task.DoNotFailOnError(); } return(task.Execute(context)); }
/// <inheritdoc /> protected override TResult DoExecute(ITaskContextInternal context) { if (string.IsNullOrEmpty(ExecutablePath)) { throw new TaskExecutionException($"{nameof(ExecutablePath)} must be set.", 5); } _task = context.Tasks() .RunProgramTask(ExecutablePath) .DoNotLogTaskExecutionInfo() .WorkingFolder(ExecuteWorkingFolder); _task.WithOutputLogLevel(OutputLogLevel); _task.WithLogLevel(TaskLogLevel); if (KeepProgramOutput) { _task.CaptureOutput(); } if (KeepProgramErrorOutput) { _task.CaptureErrorOutput(); } BeforeExecute(context, _task); AddOrOverrideArgumentsFromConsole(context); var argumentsFlat = ValidateAndGetArgumentsFlat(); foreach (var arg in argumentsFlat) { _task.WithArguments(arg.arg, arg.maskArg); } var result = _task .ChangeDefaultAdditionalOptionPrefix(AdditionalOptionPrefix) .AddPrefixToAdditionalOptionKey(_prefixToAdditionalOptionKeyFunc) .ChangeAdditionalOptionKeyValueSeperator(_additionalOptionKeyValueSeperator) .AddNewAdditionalOptionPrefix(_additionalOptionPrefixes) .Execute(context); if (typeof(TResult) == typeof(int)) { return((TResult)(object)result); } return(default(TResult)); }
protected override int DoExecute(ITaskContextInternal context) { string program = ExecutablePath; if (string.IsNullOrEmpty(program)) { program = context.Properties.GetDotnetExecutable(); } if (string.IsNullOrEmpty(program)) { context.Fail("Dotnet executable not set!", -1); return(-1); } IRunProgramTask task = context.Tasks().RunProgramTask(program); if (NoOutputLog) { task.DoNotLogOutput(); } if (DoNotLog) { task.NoLog(); } BeforeExecute(context); var argumentsFlat = ValidateAndGetArgumentsFlat(); task .WithArguments(Command); foreach (var arg in argumentsFlat) { task.WithArguments(arg.arg, arg.maskArg); } task .WorkingFolder(ExecuteWorkingFolder) .CaptureErrorOutput() .CaptureOutput() .ExecuteVoid(context); return(0); }
protected override int DoExecute(ITaskContextInternal context) { string program = _dotnetExecutable; if (string.IsNullOrEmpty(program)) { program = context.Properties.GetDotnetExecutable(); } if (string.IsNullOrEmpty(program)) { context.Fail("Dotnet executable not set!", -1); return(-1); } BeforeExecute(context); IRunProgramTask task = context.Tasks().RunProgramTask(program); if (_doNotLogOutput) { task.DoNotLogOutput(); } if (DoNotLog) { task.NoLog(); } task .WithArguments(Command) .WithArguments(Arguments.ToArray()) .WorkingFolder(_workingFolder) .CaptureErrorOutput() .CaptureOutput() .ExecuteVoid(context); return(0); }
/// <inheritdoc /> protected override int DoExecute(ITaskContextInternal context) { PrepareExecutableParameters(context); IRunProgramTask task = context.Tasks().RunProgramTask(ExecutablePath); if (NoOutputLog) { task.DoNotLogOutput(); } if (DoNotLog) { task.NoLog(); } task .CaptureErrorOutput() .CaptureOutput() .WorkingFolder(ExecuteWorkingFolder) .WithArguments(_arguments.ToArray()); return(task.Execute(context)); }