Example #1
0
        private void PerformTaskSetup(ICakeContext context, IExecutionStrategy strategy, ICakeTaskInfo task,
                                      bool skipped)
        {
            var taskSetupContext = new TaskSetupContext(context, task);

            PublishEvent(BeforeTaskSetup, new BeforeTaskSetupEventArgs(taskSetupContext));
#pragma warning disable 618
            PublishEvent(TaskSetup, new TaskSetupEventArgs(taskSetupContext));
#pragma warning restore 618
            // Trying to stay consistent with the behavior of script-level Setup & Teardown (if setup fails, don't run the task, but still run the teardown)
            try
            {
                if (_actions.TaskSetup != null)
                {
                    try
                    {
                        strategy.PerformTaskSetup(_actions.TaskSetup, taskSetupContext);
                    }
                    catch (Exception exception)
                    {
                        PerformTaskTeardown(context, strategy, task, TimeSpan.Zero, skipped, exception);
                        throw;
                    }
                }
            }
            finally
            {
                PublishEvent(AfterTaskSetup, new AfterTaskSetupEventArgs(taskSetupContext));
            }
        }
Example #2
0
 private void PerformTaskSetup(ICakeContext context, IExecutionStrategy strategy, ICakeTaskInfo task, bool skipped)
 {
     // Trying to stay consistent with the behavior of script-level Setup & Teardown (if setup fails, don't run the task, but still run the teardown)
     if (_taskSetupAction != null)
     {
         try
         {
             var taskSetupContext = new TaskSetupContext(task);
             strategy.PerformTaskSetup(_taskSetupAction, context, taskSetupContext);
         }
         catch
         {
             PerformTaskTeardown(context, strategy, task, TimeSpan.Zero, skipped, true);
             throw;
         }
     }
 }