Esempio n. 1
0
        private void SkipTask(ICakeContext context, IExecutionStrategy strategy, CakeTask task, CakeReport report,
                              CakeTaskCriteria criteria)
        {
            PerformTaskSetup(context, strategy, task, true);
            strategy.Skip(task, criteria);
            PerformTaskTeardown(context, strategy, task, TimeSpan.Zero, true, null);

            // Add the skipped task to the report.
            report.AddSkipped(task.Name);
        }
        /// <summary>
        /// Skips the specified task.
        /// </summary>
        /// <param name="task">The task to skip.</param>
        /// <param name="criteria">The criteria that caused the task to be skipped.</param>
        public void Skip(CakeTask task, CakeTaskCriteria criteria)
        {
            if (task != null)
            {
                _log.Verbose(string.Empty);
                _log.Verbose("========================================");
                _log.Verbose(task.Name);
                _log.Verbose("========================================");

                var message = string.IsNullOrWhiteSpace(criteria.Message)
                    ? task.Name : criteria.Message;

                _log.Verbose("Skipping task: {0}", message);
            }
        }
Esempio n. 3
0
 private static bool ShouldTaskExecute(ICakeContext context, CakeTask task, CakeTaskCriteria criteria, bool isTarget)
 {
     if (!criteria.Predicate(context))
     {
         if (isTarget)
         {
             // It's not OK to skip the target task.
             // See issue #106 (https://github.com/cake-build/cake/issues/106)
             const string format  = "Could not reach target '{0}' since it was skipped due to a criteria.";
             var          message = string.Format(CultureInfo.InvariantCulture, format, task.Name);
             throw new CakeException(message);
         }
         return(false);
     }
     return(true);
 }
Esempio n. 4
0
        private static bool ShouldTaskExecute(ICakeContext context, CakeTask task, CakeTaskCriteria criteria, bool isTarget)
        {
            if (!criteria.Predicate(context))
            {
                if (isTarget)
                {
                    // It's not OK to skip the target task.
                    // See issue #106 (https://github.com/cake-build/cake/issues/106)
                    var message = string.IsNullOrWhiteSpace(criteria.Message) ?
                                  $"Could not reach target '{task.Name}' since it was skipped due to a criteria." :
                                  $"Could not reach target '{task.Name}' since it was skipped due to a criteria: {criteria.Message}.";

                    throw new CakeException(message);
                }

                return(false);
            }

            return(true);
        }