Example #1
0
        /// <summary>
        /// Logs the project started/finished pair for projects which are skipped entirely because all
        /// of their results are available in the cache.
        /// </summary>
        internal void LogRequestHandledFromCache(BuildRequest request, BuildRequestConfiguration configuration, BuildResult result)
        {
            ProjectLoggingContext projectLoggingContext = LogProjectStarted(request, configuration);

            // When pulling a request from the cache, we want to make sure we log a target skipped event for any targets which
            // were used to build the request including default and initial targets.
            foreach (string target in configuration.GetTargetsUsedToBuildRequest(request))
            {
                var  targetResult = result[target];
                bool isFailure    = targetResult.ResultCode == TargetResultCode.Failure;

                var skippedTargetEventArgs = new TargetSkippedEventArgs(message: null)
                {
                    BuildEventContext         = projectLoggingContext.BuildEventContext,
                    TargetName                = target,
                    BuildReason               = TargetBuiltReason.None,
                    SkipReason                = isFailure ? TargetSkipReason.PreviouslyBuiltUnsuccessfully : TargetSkipReason.PreviouslyBuiltSuccessfully,
                    OriginallySucceeded       = !isFailure,
                    OriginalBuildEventContext = (targetResult as TargetResult)?.OriginalBuildEventContext
                };

                projectLoggingContext.LogBuildEvent(skippedTargetEventArgs);

                if (targetResult.ResultCode == TargetResultCode.Failure)
                {
                    break;
                }
            }

            projectLoggingContext.LogProjectFinished(result.OverallResult == BuildResultCode.Success);
        }
Example #2
0
        /// <summary>
        /// Creates a new target logging context from an existing project context and target.
        /// </summary>
        internal TargetLoggingContext(ProjectLoggingContext projectLoggingContext, string projectFullPath, ProjectTargetInstance target, string parentTargetName, TargetBuiltReason buildReason)
            : base(projectLoggingContext)
        {
            _projectLoggingContext = projectLoggingContext;
            _target = target;

            this.BuildEventContext = LoggingService.LogTargetStarted(projectLoggingContext.BuildEventContext, target.Name, projectFullPath, target.Location.File, parentTargetName, buildReason);
            this.IsValid           = true;
        }
Example #3
0
        /// <summary>
        /// Logs the project started/finished pair for projects which are skipped entirely because all
        /// of their results are available in the cache.
        /// </summary>
        internal void LogRequestHandledFromCache(BuildRequest request, BuildRequestConfiguration configuration, BuildResult result)
        {
            ProjectLoggingContext projectLoggingContext = LogProjectStarted(request, configuration);

            // When pulling a request from the cache, we want to make sure we log a task skipped message for any targets which
            // were used to build the request including default and inital targets.
            foreach (string target in configuration.GetTargetsUsedToBuildRequest(request))
            {
                projectLoggingContext.LogComment
                (
                    MessageImportance.Low,
                    result[target].ResultCode == TargetResultCode.Failure ? "TargetAlreadyCompleteFailure" : "TargetAlreadyCompleteSuccess",
                    target
                );

                if (result[target].ResultCode == TargetResultCode.Failure)
                {
                    break;
                }
            }

            projectLoggingContext.LogProjectFinished(result.OverallResult == BuildResultCode.Success);
        }