Skip to content

Commit 7dd37d8

Browse files
committed
Avoid BuildXL assembly load when not opted in
1 parent 01c14a7 commit 7dd37d8

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

src/Build/BackEnd/BuildManager/BuildManager.cs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -562,13 +562,7 @@ public void BeginBuild(BuildParameters parameters)
562562
#if FEATURE_REPORTFILEACCESSES
563563
if (_buildParameters.ReportFileAccesses)
564564
{
565-
// To properly report file access, we need to disable the in-proc node which won't be detoured.
566-
_buildParameters.DisableInProcNode = true;
567-
568-
// Node reuse must be disabled as future builds will not be able to listen to events raised by detours.
569-
_buildParameters.EnableNodeReuse = false;
570-
571-
_componentFactories.ReplaceFactory(BuildComponentType.NodeLauncher, DetouredNodeLauncher.CreateComponent);
565+
EnableDetouredNodeLauncher();
572566
}
573567
#endif
574568

@@ -723,6 +717,25 @@ void InitializeCaches()
723717
}
724718
}
725719

720+
#if FEATURE_REPORTFILEACCESSES
721+
/// <summary>
722+
/// Configure the build to use I/O tracking for nodes.
723+
/// </summary>
724+
/// <remarks>
725+
/// Must be a separate method to avoid loading the BuildXL assembly when not opted in.
726+
/// </remarks>
727+
private void EnableDetouredNodeLauncher()
728+
{
729+
// To properly report file access, we need to disable the in-proc node which won't be detoured.
730+
_buildParameters.DisableInProcNode = true;
731+
732+
// Node reuse must be disabled as future builds will not be able to listen to events raised by detours.
733+
_buildParameters.EnableNodeReuse = false;
734+
735+
_componentFactories.ReplaceFactory(BuildComponentType.NodeLauncher, DetouredNodeLauncher.CreateComponent);
736+
}
737+
#endif
738+
726739
private static void AttachDebugger()
727740
{
728741
if (Debugger.IsAttached)

0 commit comments

Comments
 (0)