Esempio n. 1
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();
            }
        }