/// <summary>
        /// Logs that a task has finished executing.
        /// </summary>
        /// <param name="taskBuildEventContext">Event context for the task</param>
        /// <param name="taskName">Name of the task</param>
        /// <param name="projectFile">Project which is being processed</param>
        /// <param name="projectFileOfTaskNode">Project file which contains the task</param>
        /// <param name="success">Did the task pass or fail</param>
        /// <exception cref="InternalErrorException">BuildEventContext is null</exception>
        public void LogTaskFinished(BuildEventContext taskBuildEventContext, string taskName, string projectFile, string projectFileOfTaskNode, bool success)
        {
            lock (_lockObject)
            {
                if (!OnlyLogCriticalEvents)
                {
                    ErrorUtilities.VerifyThrow(taskBuildEventContext != null, "taskBuildEventContext is null");
                    string message = ResourceUtilities.FormatResourceString((success ? "TaskFinishedSuccess" : "TaskFinishedFailure"), taskName);

                    TaskFinishedEventArgs buildEvent = new TaskFinishedEventArgs
                                                       (
                        message,
                        null,     // no help keyword
                        projectFile,
                        projectFileOfTaskNode,
                        taskName,
                        success
                                                       );
                    buildEvent.BuildEventContext = taskBuildEventContext;
                    ProcessLoggingEvent(buildEvent);
                }
            }
        }
        /// <summary>
        /// Log a comment
        /// </summary>
        /// <param name="buildEventContext">Event context information which describes who is logging the event</param>
        /// <param name="importance">How important is the message, this will determine which verbosities the message will show up on.
        /// The higher the importance the lower the verbosity needs to be for the message to be seen</param>
        /// <param name="message">Message to log</param>
        /// <param name="messageArgs">Message formatting arguments</param>
        /// <exception cref="InternalErrorException">BuildEventContext is null</exception>
        /// <exception cref="InternalErrorException">Message is null</exception>
        public void LogCommentFromText(BuildEventContext buildEventContext, MessageImportance importance, string message, params object[] messageArgs)
        {
            lock (_lockObject)
            {
                if (!OnlyLogCriticalEvents)
                {
                    ErrorUtilities.VerifyThrow(buildEventContext != null, "buildEventContext was null");
                    ErrorUtilities.VerifyThrow(message != null, "message was null");

                    BuildMessageEventArgs buildEvent = new BuildMessageEventArgs
                                                       (
                        message,
                        null,
                        "MSBuild",
                        importance,
                        DateTime.UtcNow,
                        messageArgs
                                                       );
                    buildEvent.BuildEventContext = buildEventContext;
                    ProcessLoggingEvent(buildEvent);
                }
            }
        }
Example #3
0
        /// <summary>
        /// This method creates a new routing context. This method is not thread safe and must be called
        /// only from the engine thread.
        /// </summary>
        internal int CreateRoutingContext
        (
            int nodeIndex,
            int parentHandleId,
            int parentNodeIndex,
            int parentRequestId,
            CacheScope cacheScope,
            BuildRequest triggeringBuildRequest,
            BuildEventContext buildEventContext
        )
        {
            int handleId = nextContextId;

            nextContextId = nextContextId + 1;

            RequestRoutingContext executionContext =
                new RequestRoutingContext(handleId, nodeIndex, parentHandleId, parentNodeIndex, parentRequestId,
                                          cacheScope, triggeringBuildRequest, buildEventContext);

            executionContexts.Add(handleId, executionContext);

            return(handleId);
        }
        /// <summary>
        /// Get a call stack of event contexts for a starting point event context
        /// </summary>
        internal List <ProjectStartedEventMinimumFields> GetProjectCallStack(BuildEventContext e)
        {
            List <ProjectStartedEventMinimumFields> stackTrace = new List <ProjectStartedEventMinimumFields>();

            ProjectStartedEventMinimumFields currentKey = GetProjectStartedEvent(e);

            // currentKey can be null if the stack trace is requested before the project started event has been seen
            // or if the call stack is requested by an event which is not associated with a project such as an event
            // from the engine itself
            if (currentKey != null)
            {
                //Add the event where the stack should start
                stackTrace.Add(currentKey);

                // Loop through the call tree until the root project started event has been found
                while (currentKey.ParentProjectStartedEvent != null)
                {
                    currentKey = currentKey.ParentProjectStartedEvent;
                    stackTrace.Add(currentKey);
                }
            }
            return(stackTrace);
        }
        /// <summary>
        /// Logs that a project has finished
        /// </summary>
        /// <param name="projectBuildEventContext">Event context for the project.</param>
        /// <param name="projectFile">Project file being built</param>
        /// <param name="success">Did the project pass or fail</param>
        /// <exception cref="InternalErrorException">BuildEventContext is null</exception>
        public void LogProjectFinished(BuildEventContext projectBuildEventContext, string projectFile, bool success)
        {
            lock (_lockObject)
            {
                ErrorUtilities.VerifyThrow(projectBuildEventContext != null, "projectBuildEventContext");

                ProjectFinishedEventArgs buildEvent = new ProjectFinishedEventArgs
                                                      (
                    message: null,
                    helpKeyword: null,
                    projectFile,
                    success
                                                      );
                buildEvent.BuildEventContext = projectBuildEventContext;
                ProcessLoggingEvent(buildEvent);

                // PERF: Not using VerifyThrow to avoid boxing of projectBuildEventContext.ProjectContextId in the non-error case.
                if (!_projectFileMap.Remove(projectBuildEventContext.ProjectContextId))
                {
                    ErrorUtilities.ThrowInternalError("ContextID {0} for project {1} should be in the ID-to-file mapping!", projectBuildEventContext.ProjectContextId, projectFile);
                }
            }
        }
        public void LogProjectEvaluationFinished(
            BuildEventContext projectEvaluationEventContext,
            string projectFile,
            IEnumerable globalProperties,
            IEnumerable properties,
            IEnumerable items,
            ProfilerResult?profilerResult)
        {
            ErrorUtilities.VerifyThrow(projectEvaluationEventContext != null, "projectBuildEventContext");

            ProjectEvaluationFinishedEventArgs buildEvent =
                new ProjectEvaluationFinishedEventArgs(ResourceUtilities.GetResourceString("EvaluationFinished"), projectFile)
            {
                BuildEventContext = projectEvaluationEventContext,
                ProjectFile       = projectFile,
                ProfilerResult    = profilerResult,
                GlobalProperties  = globalProperties,
                Properties        = properties,
                Items             = items
            };

            ProcessLoggingEvent(buildEvent);
        }
Example #7
0
        /// <summary>
        /// Initializes a build request with a parent context.
        /// </summary>
        /// <param name="submissionId">The id of the build submission.</param>
        /// <param name="nodeRequestId">The id of the node issuing the request</param>
        /// <param name="configurationId">The configuration id to use.</param>
        /// <param name="escapedTargets">The targets to be built</param>
        /// <param name="hostServices">Host services if any. May be null.</param>
        /// <param name="parentBuildEventContext">The build event context of the parent project.</param>
        /// <param name="parentRequest">The parent build request, if any.</param>
        /// <param name="skipStaticGraphIsolationConstraints"></param>
        /// <param name="buildRequestDataFlags">Additional flags for the request.</param>
        /// <param name="requestedProjectState">Filter for desired build results.</param>
        public BuildRequest(
            int submissionId,
            int nodeRequestId,
            int configurationId,
            ICollection <string> escapedTargets,
            HostServices hostServices,
            BuildEventContext parentBuildEventContext,
            BuildRequest parentRequest,
            BuildRequestDataFlags buildRequestDataFlags = BuildRequestDataFlags.None,
            RequestedProjectState requestedProjectState = null,
            bool skipStaticGraphIsolationConstraints    = false)
        {
            ErrorUtilities.VerifyThrowArgumentNull(escapedTargets, "targets");
            ErrorUtilities.VerifyThrowArgumentNull(parentBuildEventContext, nameof(parentBuildEventContext));

            _submissionId    = submissionId;
            _configurationId = configurationId;

            // When targets come into a build request, we unescape them.
            _targets = new List <string>(escapedTargets.Count);
            foreach (string target in escapedTargets)
            {
                _targets.Add(EscapingUtilities.UnescapeAll(target));
            }

            HostServices             = hostServices;
            _buildEventContext       = BuildEventContext.Invalid;
            _parentBuildEventContext = parentBuildEventContext;
            _globalRequestId         = InvalidGlobalRequestId;
            _parentGlobalRequestId   = parentRequest?.GlobalRequestId ?? InvalidGlobalRequestId;

            _nodeRequestId         = nodeRequestId;
            _buildRequestDataFlags = buildRequestDataFlags;
            _requestedProjectState = requestedProjectState;

            _skipStaticGraphIsolationConstraints = skipStaticGraphIsolationConstraints;
        }
Example #8
0
        public void LogInvalidProjectFileError(BuildEventContext buildEventContext, InvalidProjectFileException invalidProjectFileException)
        {
            lock (_lockObject)
            {
                ErrorUtilities.VerifyThrow(invalidProjectFileException != null, "Need exception context.");
                ErrorUtilities.VerifyThrow(buildEventContext != null, "buildEventContext is null");

                // Don't log the exception more than once.
                if (!invalidProjectFileException.HasBeenLogged)
                {
                    BuildErrorEventArgs buildEvent =
                        new BuildErrorEventArgs
                        (
                            invalidProjectFileException.ErrorSubcategory,
                            invalidProjectFileException.ErrorCode,
                            invalidProjectFileException.ProjectFile,
                            invalidProjectFileException.LineNumber,
                            invalidProjectFileException.ColumnNumber,
                            invalidProjectFileException.EndLineNumber,
                            invalidProjectFileException.EndColumnNumber,
                            invalidProjectFileException.BaseMessage,
                            invalidProjectFileException.HelpKeyword,
                            "MSBuild"
                        );
                    buildEvent.BuildEventContext = buildEventContext;
                    if (buildEvent.ProjectFile == null && buildEventContext.ProjectContextId != BuildEventContext.InvalidProjectContextId)
                    {
                        _projectFileMap.TryGetValue(buildEventContext.ProjectContextId, out string projectFile);
                        ErrorUtilities.VerifyThrow(projectFile != null, "ContextID {0} should have been in the ID-to-project file mapping but wasn't!", buildEventContext.ProjectContextId);
                        buildEvent.ProjectFile = projectFile;
                    }

                    ProcessLoggingEvent(buildEvent);
                    invalidProjectFileException.HasBeenLogged = true;
                }
            }
        }
        public void LogWarningFromText(BuildEventContext buildEventContext, string subcategoryResourceName, string warningCode, string helpKeyword, BuildEventFileInfo file, string message)
        {
            ErrorUtilities.VerifyThrow(file != null, "Must specify the associated file.");
            ErrorUtilities.VerifyThrow(message != null, "Need warning message.");
            ErrorUtilities.VerifyThrow(buildEventContext != null, "Need a BuildEventContext");

            string subcategory = null;

            if (!string.IsNullOrWhiteSpace(subcategoryResourceName))
            {
                subcategory = AssemblyResources.GetString(subcategoryResourceName);
            }

            BuildWarningEventArgs buildEvent = new BuildWarningEventArgs
                                               (
                subcategory,
                warningCode,
                file.File,
                file.Line,
                file.Column,
                file.EndLine,
                file.EndColumn,
                message,
                helpKeyword,
                "MSBuild"
                                               );

            buildEvent.BuildEventContext = buildEventContext;
            if (buildEvent.ProjectFile == null && buildEventContext.ProjectContextId != BuildEventContext.InvalidProjectContextId)
            {
                _projectFileMap.TryGetValue(buildEventContext.ProjectContextId, out string projectFile);
                ErrorUtilities.VerifyThrow(projectFile != null, "ContextID {0} should have been in the ID-to-project file mapping but wasn't!", buildEventContext.ProjectContextId);
                buildEvent.ProjectFile = projectFile;
            }

            ProcessLoggingEvent(buildEvent);
        }
        public void AssertFirstResolverErrorsSupressedWhenResolved()
        {
            // 2sdkName will cause MockSdkResolver1 to fail with an error reason. The error will not
            // be logged because MockSdkResolver2 will succeed.
            var log    = new StringBuilder();
            var sdk    = new SdkReference("2sdkName", "referencedVersion", "minimumVersion");
            var logger = new MockLoggingService(message => log.AppendLine(message));
            var bec    = new BuildEventContext(0, 0, 0, 0, 0);

            SdkResolution resolution = new SdkResolution(new MockLoaderStrategy());
            var           result     = resolution.GetSdkPath(sdk, _loggingContext, new MockElementLocation("file"), "sln", "projectPath");

            var logResult = _log.ToString();

            Assert.Equal("resolverpath2", result);

            // Both resolvers should run, and no ERROR string.
            Assert.Contains("MockSdkResolver1 running", logResult);
            Assert.Contains("MockSdkResolver2 running", logResult);

            // Resolver2 gives a warning on success or failure.
            Assert.Contains("WARNING2", logResult);
            Assert.DoesNotContain("ERROR", logResult);
        }
Example #11
0
        /// <summary>
        /// Sets the requestBatch size based on an environment variable set by the user.
        /// </summary>
        private void SetBatchRequestSize()
        {
            // The RequestBatchSize is how many buildrequests will be sent to the parent engine at once when the system
            // is running in multiproc mode. The idea of only sending a certain ammount of build requests was implemented
            // due to the parent engine being flooded with build requests if the tree being built is very broad.
            string requestBatchSizeEnvironmentVariable = Environment.GetEnvironmentVariable("MSBUILDREQUESTBATCHSIZE");

            if (!String.IsNullOrEmpty(requestBatchSizeEnvironmentVariable))
            {
                if (!int.TryParse(requestBatchSizeEnvironmentVariable, out batchRequestSize) || batchRequestSize < 1)
                {
                    // If an invalid RequestBatchSize is passed in set the batchRequestSize back to the default and log a warning.
                    batchRequestSize = defaultBatchRequestSize;
                    BuildEventContext buildEventContext = new BuildEventContext(
                        nodeId,
                        BuildEventContext.InvalidTargetId,
                        BuildEventContext.InvalidProjectContextId,
                        BuildEventContext.InvalidTaskId
                        );

                    engineCallback.GetParentEngine().LoggingServices.LogWarning(buildEventContext, new BuildEventFileInfo(/* there is truly no file associated with this warning */ String.Empty), "BatchRequestSizeOutOfRange", requestBatchSizeEnvironmentVariable);
                }
            }
        }
        /// <summary>
        /// Logs that a target has finished.
        /// </summary>
        /// <param name="targetBuildEventContext">Event context for the target</param>
        /// <param name="targetName">Target which has just finished</param>
        /// <param name="projectFile">Project file being built</param>
        /// <param name="projectFileOfTargetElement">Project file which contains the target</param>
        /// <param name="success">Did the target pass or fail</param>
        /// <param name="targetOutputs">Target outputs for the target.</param>
        /// <exception cref="InternalErrorException">BuildEventContext is null</exception>
        public void LogTargetFinished(BuildEventContext targetBuildEventContext, string targetName, string projectFile, string projectFileOfTargetElement, bool success, IEnumerable <TaskItem> targetOutputs)
        {
            lock (_lockObject)
            {
                if (!OnlyLogCriticalEvents)
                {
                    ErrorUtilities.VerifyThrow(targetBuildEventContext != null, "targetBuildEventContext is null");

                    TargetFinishedEventArgs buildEvent = new TargetFinishedEventArgs
                                                         (
                        message: null,
                        helpKeyword: null,
                        targetName,
                        projectFile,
                        projectFileOfTargetElement,
                        success,
                        targetOutputs
                                                         );

                    buildEvent.BuildEventContext = targetBuildEventContext;
                    ProcessLoggingEvent(buildEvent);
                }
            }
        }
Example #13
0
        /// <summary>
        /// Create an instance of this class to represent the IBuildEngine2 interface to the task
        /// including the event location where the log messages are raised
        /// </summary>
        /// <param name="parentModule">Parent Task Execution Module</param>
        /// <param name="handleId"></param>
        /// <param name="parentProjectFullFileName">the full path to the currently building project</param>
        /// <param name="projectFileOfTaskNode">the path to the actual file (project or targets) where the task invocation is located</param>
        /// <param name="loggingServices"></param>
        /// <param name="buildEventContext">Event Context where events will be seen to be raised from. Task messages will get this as their event context</param>
        internal EngineProxy
        (
            TaskExecutionModule parentModule,
            int handleId,
            string parentProjectFullFileName,
            string projectFileOfTaskNode,
            EngineLoggingServices loggingServices,
            BuildEventContext buildEventContext
        )
        {
            ErrorUtilities.VerifyThrow(parentModule != null, "No parent module.");
            ErrorUtilities.VerifyThrow(loggingServices != null, "No logging services.");
            ErrorUtilities.VerifyThrow(projectFileOfTaskNode != null, "Need project file path string");

            this.parentModule = parentModule;
            this.handleId     = handleId;
            this.parentProjectFullFileName = parentProjectFullFileName;
            this.projectFileOfTaskNode     = projectFileOfTaskNode;
            this.loggingServices           = loggingServices;
            this.buildEventContext         = buildEventContext;
            this.callbackMonitor           = new object();

            activeProxy = true;
        }
Example #14
0
        private TreeNode FindParent(BuildEventContext buildEventContext)
        {
            Project  project = GetOrAddProject(buildEventContext.ProjectContextId);
            TreeNode result  = project;

            if (buildEventContext.TargetId > 0)
            {
                var target = project.GetTargetById(buildEventContext.TargetId);
                if (target != null)
                {
                    result = target;
                    if (buildEventContext.TaskId > 0)
                    {
                        var task = target.GetTaskById(buildEventContext.TaskId);
                        if (task != null)
                        {
                            result = task;
                        }
                    }
                }
            }

            return(result);
        }
Example #15
0
 /// <summary>
 /// Logs a target finished event
 /// </summary>
 /// <param name="targetBuildEventContext">The target's build event context</param>
 /// <param name="targetName">The name of the target</param>
 /// <param name="projectFile">The project file</param>
 /// <param name="projectFileOfTargetElement">The project file containing the target element</param>
 /// <param name="success">Whether it was successful or not.</param>
 public void LogTargetFinished(BuildEventContext targetBuildEventContext, string targetName, string projectFile, string projectFileOfTargetElement, bool success, IEnumerable <TaskItem> targetOutputs)
 {
 }
Example #16
0
 /// <summary>
 /// Logs a target started event
 /// </summary>
 /// <param name="projectBuildEventContext">The build event context of the project</param>
 /// <param name="targetName">The name of the target</param>
 /// <param name="projectFile">The project file</param>
 /// <param name="projectFileOfTargetElement">The project file containing the target element</param>
 /// <returns>The build event context for the target</returns>
 public BuildEventContext LogTargetStarted(BuildEventContext projectBuildEventContext, string targetName, string projectFile, string projectFileOfTargetElement, string parentTargetName)
 {
     return(new BuildEventContext(0, 0, 0, 0));
 }
Example #17
0
 /// <summary>
 /// Logs a project finished event
 /// </summary>
 /// <param name="projectBuildEventContext">The project build event context</param>
 /// <param name="projectFile">The project filename</param>
 /// <param name="success">Whether it was successful or not.</param>
 public void LogProjectFinished(BuildEventContext projectBuildEventContext, string projectFile, bool success)
 {
 }
Example #18
0
 /// <summary>
 /// Logs a project started event
 /// </summary>
 public BuildEventContext LogProjectStarted(BuildEventContext nodeBuildEventContext, int submissionId, int projectId, BuildEventContext parentBuildEventContext, string projectFile, string targetNames, IEnumerable <DictionaryEntry> properties, IEnumerable <DictionaryEntry> items)
 {
     return(new BuildEventContext(0, 0, 0, 0));
 }
Example #19
0
 /// <summary>
 /// Logs a text warning
 /// </summary>
 /// <param name="buildEventContext">The build context</param>
 /// <param name="subcategoryResourceName">The subcategory resource</param>
 /// <param name="warningCode">The warning code</param>
 /// <param name="helpKeyword">A help keyword</param>
 /// <param name="file">The file</param>
 /// <param name="message">The message</param>
 public void LogWarningFromText(BuildEventContext buildEventContext, string subcategoryResourceName, string warningCode, string helpKeyword, BuildEventFileInfo file, string message)
 {
     Console.WriteLine(message);
 }
Example #20
0
 /// <summary>
 /// Logs a task warning
 /// </summary>
 /// <param name="buildEventContext">The build context</param>
 /// <param name="exception">The exception</param>
 /// <param name="file">The file</param>
 /// <param name="taskName">The name of the task</param>
 public void LogTaskWarningFromException(BuildEventContext buildEventContext, Exception exception, BuildEventFileInfo file, string taskName)
 {
 }
Example #21
0
 /// <summary>
 /// Logs a generic fatal error
 /// </summary>
 /// <param name="buildEventContext">The build context</param>
 /// <param name="exception">The exception</param>
 /// <param name="file">The file</param>
 /// <param name="messageResourceName">The message resource</param>
 /// <param name="messageArgs">The message args</param>
 public void LogFatalError(BuildEventContext buildEventContext, Exception exception, BuildEventFileInfo file, string messageResourceName, params object[] messageArgs)
 {
 }
Example #22
0
 /// <summary>
 /// Logs a fatal task error
 /// </summary>
 /// <param name="buildEventContext">The event context</param>
 /// <param name="exception">The exception</param>
 /// <param name="file">The file</param>
 /// <param name="taskName">The name of the task</param>
 public void LogFatalTaskError(BuildEventContext buildEventContext, Exception exception, BuildEventFileInfo file, string taskName)
 {
 }
Example #23
0
 /// <summary>
 /// Logs a task started event
 /// </summary>
 /// <param name="targetBuildEventContext">The target's build event context</param>
 /// <param name="taskName">The name of the task</param>
 /// <param name="projectFile">The project file</param>
 /// <param name="projectFileOfTaskNode">The project file containing the task node.</param>
 public void LogTaskStarted(BuildEventContext targetBuildEventContext, string taskName, string projectFile, string projectFileOfTaskNode)
 {
 }
Example #24
0
 /// <summary>
 /// Logs a task finished event
 /// </summary>
 /// <param name="taskBuildEventContext">The task's build event context</param>
 /// <param name="taskName">The name of the task</param>
 /// <param name="projectFile">The project file</param>
 /// <param name="projectFileOfTaskNode">The project file of the task node</param>
 /// <param name="success">Whether the task was successful or not.</param>
 public void LogTaskFinished(BuildEventContext taskBuildEventContext, string taskName, string projectFile, string projectFileOfTaskNode, bool success)
 {
 }
Example #25
0
 /// <summary>
 /// Logs a task started event
 /// </summary>
 /// <param name="targetBuildEventContext">The target's build event context</param>
 /// <param name="taskName">The name of the task</param>
 /// <param name="projectFile">The project file</param>
 /// <param name="projectFileOfTaskNode">The project file containing the task node.</param>
 /// <returns>The task logging context</returns>
 public BuildEventContext LogTaskStarted2(BuildEventContext targetBuildEventContext, string taskName, string projectFile, string projectFileOfTaskNode)
 {
     return(new BuildEventContext(0, 0, 0, 0));
 }
Example #26
0
 /// <summary>
 /// Logs a text comment
 /// </summary>
 /// <param name="buildEventContext">The context</param>
 /// <param name="importance">The importance</param>
 /// <param name="message">The message</param>
 public void LogCommentFromText(BuildEventContext buildEventContext, MessageImportance importance, string message)
 {
     Console.WriteLine(message);
 }
Example #27
0
        /// <summary>
        /// Logs that a project build has started
        /// </summary>
        /// <param name="nodeBuildEventContext">The event context of the node which is spawning this project.</param>
        /// <param name="submissionId">The id of the submission.</param>
        /// <param name="projectInstanceId">Id of the project instance which is being started</param>
        /// <param name="parentBuildEventContext">BuildEventContext of the project who is requesting "projectFile" to build</param>
        /// <param name="projectFile">Project file to build</param>
        /// <param name="targetNames">Target names to build</param>
        /// <param name="properties">Initial property list</param>
        /// <param name="items">Initial items list</param>
        /// <returns>The build event context for the project.</returns>
        /// <exception cref="InternalErrorException">parentBuildEventContext is null</exception>
        /// <exception cref="InternalErrorException">projectBuildEventContext is null</exception>
        public BuildEventContext LogProjectStarted(BuildEventContext nodeBuildEventContext, int submissionId, int projectInstanceId, BuildEventContext parentBuildEventContext, string projectFile, string targetNames, IEnumerable <DictionaryEntry> properties, IEnumerable <DictionaryEntry> items)
        {
            lock (_lockObject)
            {
                ErrorUtilities.VerifyThrow(nodeBuildEventContext != null, "Need a nodeBuildEventContext");
                BuildEventContext projectBuildEventContext = new BuildEventContext(submissionId, nodeBuildEventContext.NodeId, projectInstanceId, NextProjectId, BuildEventContext.InvalidTargetId, BuildEventContext.InvalidTaskId);

                // PERF: Not using VerifyThrow to avoid boxing of projectBuildEventContext.ProjectContextId in the non-error case.
                if (_projectFileMap.ContainsKey(projectBuildEventContext.ProjectContextId))
                {
                    ErrorUtilities.ThrowInternalError("ContextID {0} for project {1} should not already be in the ID-to-file mapping!", projectBuildEventContext.ProjectContextId, projectFile);
                }

                _projectFileMap[projectBuildEventContext.ProjectContextId] = projectFile;

                ErrorUtilities.VerifyThrow(parentBuildEventContext != null, "Need a parentBuildEventContext");

                string message         = string.Empty;
                string projectFilePath = Path.GetFileName(projectFile);

                // Check to see if the there are any specific target names to be built.
                // If targetNames is null or empty then we will be building with the
                // default targets.
                if (!String.IsNullOrEmpty(targetNames))
                {
                    message = ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword("ProjectStartedPrefixForTopLevelProjectWithTargetNames", projectFilePath, targetNames);
                }
                else
                {
                    message = ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword("ProjectStartedPrefixForTopLevelProjectWithDefaultTargets", projectFilePath);
                }

                ErrorUtilities.VerifyThrow(_configCache.Value.HasConfiguration(projectInstanceId), "Cannot find the project configuration while injecting non-serialized data from out-of-proc node.");
                var buildRequestConfiguration      = _configCache.Value[projectInstanceId];
                ProjectStartedEventArgs buildEvent = new ProjectStartedEventArgs
                                                     (
                    projectInstanceId,
                    message,
                    null,           // no help keyword
                    projectFile,
                    targetNames,
                    properties,
                    items,
                    parentBuildEventContext,
                    buildRequestConfiguration.GlobalProperties.ToDictionary(),
                    buildRequestConfiguration.ToolsVersion
                                                     );
                buildEvent.BuildEventContext = projectBuildEventContext;

                ProcessLoggingEvent(buildEvent);

                return(projectBuildEventContext);
            }
        }
Example #28
0
 /// <summary>
 /// Logs an invalid project file error
 /// </summary>
 /// <param name="buildEventContext">The event context</param>
 /// <param name="invalidProjectFileException">The exception</param>
 public void LogInvalidProjectFileError(BuildEventContext buildEventContext, InvalidProjectFileException invalidProjectFileException)
 {
 }
Example #29
0
 private string ToString(BuildEventContext context)
 {
     return($"{context.BuildRequestId} {context.NodeId} {context.ProjectContextId} {context.ProjectInstanceId} {context.SubmissionId} {context.TargetId} {context.TaskId}");
 }
Example #30
0
 /// <summary>
 /// Logs a fatal build error
 /// </summary>
 /// <param name="buildEventContext">The event context</param>
 /// <param name="exception">The exception</param>
 /// <param name="file">The file</param>
 public void LogFatalBuildError(BuildEventContext buildEventContext, Exception exception, BuildEventFileInfo file)
 {
 }