Skip to content

Commit 66286d5

Browse files
Workaround for "MSB4166: Child node "1" exited prematurely for build check (#11384)
1 parent 990a07e commit 66286d5

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the MIT license. See License.txt in the project root for full license information. -->
33
<Project>
44
<PropertyGroup>
5-
<VersionPrefix>17.12.29</VersionPrefix>
5+
<VersionPrefix>17.12.30</VersionPrefix>
66
<DotNetFinalVersionKind>release</DotNetFinalVersionKind>
77
<PackageValidationBaselineVersion>17.11.4</PackageValidationBaselineVersion>
88
<AssemblyVersion>15.1.0.0</AssemblyVersion>

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ internal enum LoggingServiceState
7272
/// </summary>
7373
internal partial class LoggingService : ILoggingService, INodePacketHandler
7474
{
75+
/// <summary>
76+
/// Gets or sets a value if BuildCheck is enabled. The presence of this flag influences the logging logic.
77+
/// </summary>
78+
private bool _buildCheckEnabled;
79+
7580
/// <summary>
7681
/// The default maximum size for the logging event queue.
7782
/// </summary>
@@ -871,6 +876,8 @@ public void InitializeComponent(IBuildComponentHost buildComponentHost)
871876
_serviceState = LoggingServiceState.Initialized;
872877

873878
_buildEngineDataRouter = (buildComponentHost.GetComponent(BuildComponentType.BuildCheckManagerProvider) as IBuildCheckManagerProvider)?.BuildEngineDataRouter;
879+
880+
_buildCheckEnabled = buildComponentHost.BuildParameters.IsBuildCheckEnabled;
874881
}
875882
}
876883

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -615,10 +615,15 @@ public void LogProjectFinished(BuildEventContext projectBuildEventContext, strin
615615
buildEvent.BuildEventContext = projectBuildEventContext;
616616
ProcessLoggingEvent(buildEvent);
617617

618-
// PERF: Not using VerifyThrow to avoid boxing of projectBuildEventContext.ProjectContextId in the non-error case.
619-
if (!_projectFileMap.TryRemove(projectBuildEventContext.ProjectContextId, out _))
618+
// BuildCheck can still emit some LogBuildEvent(s) after ProjectFinishedEventArgs was reported.
619+
// Due to GetAndVerifyProjectFileFromContext validation, these checks break the build.
620+
if (!_buildCheckEnabled)
620621
{
621-
ErrorUtilities.ThrowInternalError("ContextID {0} for project {1} should be in the ID-to-file mapping!", projectBuildEventContext.ProjectContextId, projectFile);
622+
// PERF: Not using VerifyThrow to avoid boxing of projectBuildEventContext.ProjectContextId in the non-error case.
623+
if (!_projectFileMap.TryRemove(projectBuildEventContext.ProjectContextId, out _))
624+
{
625+
ErrorUtilities.ThrowInternalError("ContextID {0} for project {1} should be in the ID-to-file mapping!", projectBuildEventContext.ProjectContextId, projectFile);
626+
}
622627
}
623628
}
624629

0 commit comments

Comments
 (0)