Пример #1
0
        public static void Execute(NukeBuild build, [CanBeNull] IReadOnlyCollection <string> skippedTargets)
        {
            MarkSkippedTargets(build, skippedTargets);
            RequirementService.ValidateRequirements(build, build.ExecutingTargets.ToList());
            var previouslyExecutedTargets = UpdateInvocationHash();

            BuildManager.CancellationHandler += ExecuteAssuredTargets;

            try
            {
                build.ExecutionPlan.ForEach(x => Execute(build, x, previouslyExecutedTargets));
            }
            catch
            {
                ExecuteAssuredTargets();
                throw;
            }

            void ExecuteAssuredTargets()
            {
                var assuredTargets = build.ExecutionPlan.Where(x => x.AssuredAfterFailure && x.Status == ExecutionStatus.NotRun);

                assuredTargets.ForEach(x => Execute(build, x, previouslyExecutedTargets, failureMode: true));
            }
        }
Пример #2
0
        public static int Execute <T>(Expression <Func <T, Target> > defaultTargetExpression)
            where T : NukeBuild
        {
            var executionList = default(IReadOnlyCollection <TargetDefinition>);
            var build         = CreateBuildInstance(defaultTargetExpression);

            HandleCompletion(build);
            CheckActiveBuildProjectConfigurations();
            AttachVisualStudioDebugger();

            try
            {
                build.OnBuildCreated();

                Logger.OutputSink = build.OutputSink;
                Logger.LogLevel   = NukeBuild.LogLevel;
                ToolPathResolver.NuGetPackagesConfigFile = build.NuGetPackagesConfigFile;

                Logger.Log($"NUKE Execution Engine {typeof(BuildExecutor).Assembly.GetInformationalText()}");
                Logger.Log(FigletTransform.GetText("NUKE"));

                HandleEarlyExits(build);
                ProcessManager.CheckPathEnvironmentVariable();
                InjectionUtility.InjectValues(build);

                executionList = TargetDefinitionLoader.GetExecutingTargets(build, NukeBuild.InvokedTargets, NukeBuild.SkippedTargets);
                RequirementService.ValidateRequirements(executionList, build);

                build.OnBuildInitialized();

                Execute(build, executionList);

                return(0);
            }
            catch (Exception exception)
            {
                Logger.Error(exception);
                return(-1);
            }
            finally
            {
                if (Logger.OutputSink is SevereMessagesOutputSink outputSink)
                {
                    Logger.Log();
                    WriteWarningsAndErrors(outputSink);
                }

                if (executionList != null)
                {
                    Logger.Log();
                    WriteSummary(executionList);
                }

                build.OnBuildFinished();
            }
        }
Пример #3
0
        public static int Execute <T>(Expression <Func <T, Target> > defaultTargetExpression)
            where T : NukeBuild
        {
            Logger.Log(FigletTransform.GetText("NUKE"));
            Logger.Log($"Version: {typeof(BuildExecutor).GetTypeInfo().Assembly.GetVersionText()}");
            Logger.Log($"Host: {EnvironmentInfo.HostType}");
            Logger.Log();

            var executionList = default(IReadOnlyCollection <TargetDefinition>);

            try
            {
                var build = CreateBuildInstance(defaultTargetExpression);
                InjectionService.InjectValues(build);
                HandleEarlyExits(build);

                executionList = TargetDefinitionLoader.GetExecutingTargets(build);
                RequirementService.ValidateRequirements(executionList, build);
                Execute(executionList);

                return(0);
            }
            catch (AggregateException exception)
            {
                foreach (var innerException in exception.Flatten().InnerExceptions)
                {
                    OutputSink.Error(innerException.Message, innerException.StackTrace);
                }
                return(-exception.Message.GetHashCode());
            }
            catch (TargetInvocationException exception)
            {
                var innerException = exception.InnerException.NotNull();
                OutputSink.Error(innerException.Message, innerException.StackTrace);
                return(-exception.Message.GetHashCode());
            }
            catch (Exception exception)
            {
                OutputSink.Error(exception.Message, exception.StackTrace);
                return(-exception.Message.GetHashCode());
            }
            finally
            {
                if (executionList != null)
                {
                    OutputSink.WriteSummary(executionList);
                }
            }
        }
Пример #4
0
        public static int Execute <T>(Expression <Func <T, Target> > defaultTargetExpression)
            where T : NukeBuild
        {
            var executionList = default(IReadOnlyCollection <TargetDefinition>);

            try
            {
                var build = CreateBuildInstance(defaultTargetExpression);

                Logger.OutputSink = build.OutputSink;
                Logger.LogLevel   = build.LogLevel;
                NuGetPackageResolver.DefaultPackagesConfigFile = build.PackagesConfigFile;

                Logger.Log(FigletTransform.GetText("NUKE"));
                Logger.Log($"Version: {typeof(BuildExecutor).GetTypeInfo().Assembly.GetInformationalText()}");
                Logger.Log($"Host: {build.Host}");
                Logger.Log();

                ProcessManager.CheckPathEnvironmentVariable();
                InjectionService.InjectValues(build);
                HandleEarlyExits(build);

                executionList = TargetDefinitionLoader.GetExecutingTargets(build, build.InvokedTargets);
                RequirementService.ValidateRequirements(executionList, build);
                Execute(executionList);

                return(0);
            }
            catch (Exception exception)
            {
                Logger.Error(exception);
                return(-1);
            }
            finally
            {
                if (Logger.OutputSink is SevereMessagesOutputSink outputSink)
                {
                    Logger.Log();
                    WriteWarningsAndErrors(outputSink);
                }

                if (executionList != null)
                {
                    Logger.Log();
                    WriteSummary(executionList);
                }
            }
        }