@@ -46,7 +46,8 @@ internal ProjectLoggingContext(NodeLoggingContext nodeLoggingContext, BuildReque
4646 requestEntry . RequestConfiguration . Project . ItemsToBuildWith ,
4747 requestEntry . Request . ParentBuildEventContext ,
4848 requestEntry . RequestConfiguration . ProjectEvaluationId ,
49- requestEntry . Request . ProjectContextId )
49+ requestEntry . Request . ProjectContextId ,
50+ requestEntry . Request . ScheduledNodeId )
5051 {
5152 }
5253
@@ -56,22 +57,22 @@ internal ProjectLoggingContext(NodeLoggingContext nodeLoggingContext, BuildReque
5657 internal ProjectLoggingContext (
5758 NodeLoggingContext nodeLoggingContext ,
5859 BuildRequest request ,
59- string projectFullPath ,
60- string toolsVersion ,
61- int evaluationId )
60+ BuildRequestConfiguration configuration )
6261 : this
6362 (
6463 nodeLoggingContext ,
6564 request . SubmissionId ,
6665 request . ConfigurationId ,
67- projectFullPath ,
66+ configuration . ProjectFullPath ,
6867 request . Targets ,
69- toolsVersion ,
68+ configuration . ToolsVersion ,
7069 projectProperties : null ,
7170 projectItems : null ,
7271 request . ParentBuildEventContext ,
73- evaluationId ,
74- request . ProjectContextId )
72+ // if the project was built on a different node, the evaluation id will be a lie anyway, make that super clear
73+ configuration . ResultsNodeId != nodeLoggingContext . BuildEventContext . NodeId ? int . MaxValue : configuration . ProjectEvaluationId ,
74+ request . ProjectContextId ,
75+ configuration . ResultsNodeId )
7576 {
7677 }
7778
@@ -93,7 +94,9 @@ public static (ProjectStartedEventArgs, ProjectLoggingContext) CreateLoggingCont
9394 requestEntry . RequestConfiguration . Project . ItemsToBuildWith ,
9495 requestEntry . Request . ParentBuildEventContext ,
9596 requestEntry . RequestConfiguration . ProjectEvaluationId ,
96- requestEntry . Request . ProjectContextId ) ;
97+ requestEntry . Request . ProjectContextId ,
98+ // in this scenario we are on the same node, so just use the current node id
99+ nodeLoggingContext . BuildEventContext . NodeId ) ;
97100
98101 return ( args , new ProjectLoggingContext ( nodeLoggingContext , args ) ) ;
99102 }
@@ -117,6 +120,18 @@ private ProjectLoggingContext(
117120 /// <summary>
118121 /// Constructs a project logging contexts.
119122 /// </summary>
123+ /// <param name="nodeLoggingContext">The node logging context for the currently executing node.</param>
124+ /// <param name="submissionId">The submission id for this project.</param>
125+ /// <param name="configurationId">The configuration id for this project.</param>
126+ /// <param name="projectFullPath">The full path to the project file.</param>
127+ /// <param name="targets">The targets being built in this project.</param>
128+ /// <param name="toolsVersion">The tools version for this project.</param>
129+ /// <param name="projectProperties">The properties in the project.</param>
130+ /// <param name="projectItems">The items in the project.</param>
131+ /// <param name="parentBuildEventContext">The parent build event context.</param>
132+ /// <param name="evaluationId">The evaluation id for this project.</param>
133+ /// <param name="projectContextId">The project context id for this project.</param>
134+ /// <param name="hostNodeId">The node id hosting this project - may be different from that of the nodeLoggingContext if this project was actually started/built on another node</param>
120135 private ProjectLoggingContext (
121136 NodeLoggingContext nodeLoggingContext ,
122137 int submissionId ,
@@ -128,7 +143,8 @@ private ProjectLoggingContext(
128143 IItemDictionary < ProjectItemInstance > projectItems ,
129144 BuildEventContext parentBuildEventContext ,
130145 int evaluationId ,
131- int projectContextId )
146+ int projectContextId ,
147+ int hostNodeId )
132148 : base ( nodeLoggingContext ,
133149 CreateInitialContext ( nodeLoggingContext ,
134150 submissionId ,
@@ -140,7 +156,8 @@ private ProjectLoggingContext(
140156 projectItems ,
141157 parentBuildEventContext ,
142158 evaluationId ,
143- projectContextId ) )
159+ projectContextId ,
160+ hostNodeId ) )
144161 {
145162 _projectFullPath = projectFullPath ;
146163
@@ -164,7 +181,8 @@ private static BuildEventContext CreateInitialContext(
164181 IItemDictionary < ProjectItemInstance > projectItems ,
165182 BuildEventContext parentBuildEventContext ,
166183 int evaluationId ,
167- int projectContextId )
184+ int projectContextId ,
185+ int hostNodeId )
168186 {
169187 ProjectStartedEventArgs args = CreateProjectStarted (
170188 nodeLoggingContext ,
@@ -177,7 +195,8 @@ private static BuildEventContext CreateInitialContext(
177195 projectItems ,
178196 parentBuildEventContext ,
179197 evaluationId ,
180- projectContextId ) ;
198+ projectContextId ,
199+ hostNodeId ) ;
181200
182201 nodeLoggingContext . LoggingService . LogProjectStarted ( args ) ;
183202
@@ -195,7 +214,8 @@ private static ProjectStartedEventArgs CreateProjectStarted(
195214 IItemDictionary < ProjectItemInstance > projectItems ,
196215 BuildEventContext parentBuildEventContext ,
197216 int evaluationId ,
198- int projectContextId )
217+ int projectContextId ,
218+ int hostNodeId )
199219 {
200220 IEnumerable < DictionaryEntry > properties = null ;
201221 IEnumerable < DictionaryEntry > items = null ;
@@ -246,7 +266,8 @@ private static ProjectStartedEventArgs CreateProjectStarted(
246266 }
247267
248268 return loggingService . CreateProjectStarted (
249- nodeLoggingContext . BuildEventContext ,
269+ // adjust the message to come from the node that actually built the project
270+ nodeLoggingContext . BuildEventContext . WithNodeId ( hostNodeId ) ,
250271 submissionId ,
251272 configurationId ,
252273 parentBuildEventContext ,
0 commit comments