Skip to content

Commit b2c4bf0

Browse files
committed
Transfer evaluation ids across nodes too!
1 parent 44fb1fa commit b2c4bf0

File tree

6 files changed

+44
-4
lines changed

6 files changed

+44
-4
lines changed

src/Build/BackEnd/BuildManager/BuildManager.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2496,6 +2496,11 @@ private void HandleResult(int node, BuildResult result)
24962496
configuration.ProjectDefaultTargets ??= result.DefaultTargets;
24972497
configuration.ProjectInitialTargets ??= result.InitialTargets;
24982498
configuration.ProjectTargets ??= result.ProjectTargets;
2499+
// Update the evaluation ID if it's valid (not InvalidEvaluationId)
2500+
if (result.EvaluationId != BuildEventContext.InvalidEvaluationId)
2501+
{
2502+
configuration.ProjectEvaluationId = result.EvaluationId;
2503+
}
24992504
}
25002505

25012506
// Only report results to the project cache services if it's the result for a build submission.

src/Build/BackEnd/Components/BuildRequestEngine/BuildRequestEngine.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,7 @@ private void EvaluateRequestStates()
852852
completedEntry.Result.DefaultTargets = configuration.ProjectDefaultTargets;
853853
completedEntry.Result.InitialTargets = configuration.ProjectInitialTargets;
854854
completedEntry.Result.ProjectTargets = configuration.ProjectTargets;
855+
completedEntry.Result.EvaluationId = configuration.ProjectEvaluationId;
855856
}
856857

857858
TraceEngine("ERS: Request is now {0}({1}) (nr {2}) has had its builder cleaned up.", completedEntry.Request.GlobalRequestId, completedEntry.Request.ConfigurationId, completedEntry.Request.NodeRequestId);

src/Build/BackEnd/Components/Logging/ProjectLoggingContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ internal ProjectLoggingContext(
7070
projectItems: null,
7171
request.ParentBuildEventContext,
7272
// 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,
73+
configuration.ProjectEvaluationId,
7474
request.ProjectContextId,
7575
configuration.ResultsNodeId)
7676
{

src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,8 @@ private async Task RequestThreadProc(bool setThreadParameters)
865865
{
866866
ErrorUtilities.VerifyThrow(result == null, "Result already set when exception was thrown.");
867867
result = new BuildResult(_requestEntry.Request, thrownException);
868+
// Populate the evaluation ID from the configuration for sending to the central node
869+
result.EvaluationId = _requestEntry.RequestConfiguration.ProjectEvaluationId;
868870
}
869871

870872
ReportResultAndCleanUp(result);
@@ -1019,7 +1021,10 @@ private BuildResult[] GetResultsForContinuation(FullyQualifiedBuildRequest[] req
10191021
results = new Dictionary<int, BuildResult>();
10201022
for (int i = 0; i < requests.Length; i++)
10211023
{
1022-
results[i] = new BuildResult(new BuildRequest(), new BuildAbortedException());
1024+
var result = new BuildResult(new BuildRequest(), new BuildAbortedException());
1025+
// Populate the evaluation ID from the configuration for sending to the central node
1026+
result.EvaluationId = _requestEntry.RequestConfiguration.ProjectEvaluationId;
1027+
results[i] = result;
10231028
}
10241029
}
10251030

@@ -1210,6 +1215,9 @@ private async Task<BuildResult> BuildProject()
12101215
BuildResult result = await _targetBuilder.BuildTargets(_projectLoggingContext, _requestEntry, this,
12111216
allTargets, _requestEntry.RequestConfiguration.BaseLookup, _cancellationTokenSource.Token);
12121217

1218+
// Populate the evaluation ID from the configuration for sending to the central node
1219+
result.EvaluationId = _requestEntry.RequestConfiguration.ProjectEvaluationId;
1220+
12131221
UpdateStatisticsPostBuild();
12141222

12151223
result = _requestEntry.Request.ProxyTargets == null

src/Build/BackEnd/Shared/BuildRequestConfiguration.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,11 @@ internal BuildRequestConfiguration()
300300
/// <summary>
301301
/// A short
302302
/// </summary>
303-
public int ProjectEvaluationId => _projectEvaluationId;
303+
public int ProjectEvaluationId
304+
{
305+
get => _projectEvaluationId;
306+
internal set => _projectEvaluationId = value;
307+
}
304308

305309
/// <summary>
306310
/// Flag indicating if this configuration represents a traversal project. Traversal projects

src/Build/BackEnd/Shared/BuildResult.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ public class BuildResult : BuildResultBase, INodePacket, IBuildResults
8686
/// <remarks>
8787
/// Allows to serialize and deserialize different versions of the build result.
8888
/// </remarks>
89-
private int _version = Traits.Instance.EscapeHatches.DoNotVersionBuildResult ? 0 : 1;
89+
private int _version =
90+
Traits.Instance.EscapeHatches.DoNotVersionBuildResult ? 0 : 2;
9091

9192
/// <summary>
9293
/// The request caused a circular dependency in scheduling.
@@ -100,6 +101,11 @@ public class BuildResult : BuildResultBase, INodePacket, IBuildResults
100101
/// </summary>
101102
private Exception? _requestException;
102103

104+
/// <summary>
105+
/// The evaluation ID of the project used for this build.
106+
/// </summary>
107+
private int _evaluationId = BuildEventContext.InvalidEvaluationId;
108+
103109
/// <summary>
104110
/// The overall result calculated in the constructor.
105111
/// </summary>
@@ -495,6 +501,17 @@ internal HashSet<string>? ProjectTargets
495501
set => _projectTargets = value;
496502
}
497503

504+
/// <summary>
505+
/// The evaluation ID of the project used for this build.
506+
/// </summary>
507+
internal int EvaluationId
508+
{
509+
[DebuggerStepThrough]
510+
get => _evaluationId;
511+
[DebuggerStepThrough]
512+
set => _evaluationId = value;
513+
}
514+
498515
/// <summary>
499516
/// Container used to transport errors from the scheduler (issued while computing a build result)
500517
/// to the TaskHost that has the proper logging context (project id, target id, task id, file location)
@@ -695,6 +712,11 @@ void ITranslatable.Translate(ITranslator translator)
695712
{
696713
translator.TranslateEnum(ref _buildRequestDataFlags, (int)_buildRequestDataFlags);
697714
}
715+
716+
if (_version >= 2)
717+
{
718+
translator.Translate(ref _evaluationId);
719+
}
698720
}
699721

700722
/// <summary>

0 commit comments

Comments
 (0)