Exemple #1
0
 public static int Execute <T> (Expression <Func <T, Target> > defaultTargetExpression)
     where T : NukeBuild
 {
     try
     {
         var executionList = Setup(defaultTargetExpression);
         return(new ExecutionListRunner().Run(executionList));
     }
     catch (Exception ex)
     {
         OutputSink.Fail(ex.Message, ex.StackTrace);
         return(-ex.Message.GetHashCode());
     }
 }
Exemple #2
0
        public int Run(IReadOnlyCollection <TargetDefinition> executionList)
        {
            foreach (var target in executionList)
            {
                if (target.Factory == null)
                {
                    target.Status = ExecutionStatus.Absent;
                    continue;
                }

                if (target.Conditions.Any(x => !x()))
                {
                    target.Status = ExecutionStatus.Skipped;
                    continue;
                }

                using (Logger.Block(target.Name))
                {
                    var stopwatch = Stopwatch.StartNew();
                    try
                    {
                        target.Actions.ForEach(x => x());
                        target.Duration = stopwatch.Elapsed;

                        target.Status = ExecutionStatus.Executed;
                    }
                    catch (Exception exception)
                    {
                        OutputSink.Fail(exception.Message, exception.StackTrace);
                        target.Status = ExecutionStatus.Failed;

                        break;
                    }
                    finally
                    {
                        target.Duration = stopwatch.Elapsed;
                    }
                }
            }

            OutputSink.WriteSummary(executionList);

            return(-executionList.Count(x => x.Status == ExecutionStatus.Failed));
        }