From 18d4f03c83979f29c80bec060587ff9d601af452 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 15 Jan 2026 15:38:23 +0000 Subject: [PATCH 1/4] Initial plan From b67673e18e9875326e24ecaec07d1f6be6f18129 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 15 Jan 2026 16:06:11 +0000 Subject: [PATCH 2/4] Fix MSB1025 error when using DistributedFileLogger with null central logger Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com> --- src/MSBuild.UnitTests/XMake_Tests.cs | 38 ++++++++++++++++++++++++++++ src/MSBuild/XMake.cs | 4 +-- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/MSBuild.UnitTests/XMake_Tests.cs b/src/MSBuild.UnitTests/XMake_Tests.cs index 3ebfcae6615..cc492e9b4ed 100644 --- a/src/MSBuild.UnitTests/XMake_Tests.cs +++ b/src/MSBuild.UnitTests/XMake_Tests.cs @@ -2294,6 +2294,44 @@ public void TestProcessFileLoggerSwitch5() distributedLoggerRecords.Count.ShouldBe(0); // "Expected no distributed loggers to be attached" loggers.Count.ShouldBe(0); // "Expected no central loggers to be attached" } + + /// + /// Verify that DistributedLoggerRecords with null CentralLogger don't cause exceptions when creating ProjectCollection + /// This is a regression test for the issue where -dfl flag caused MSB1025 error due to null logger not being filtered. + /// + [Fact] + public void TestNullCentralLoggerInDistributedLoggerRecord() + { + // Simulate the scenario when using -dfl flag + // ProcessDistributedFileLogger creates a DistributedLoggerRecord with null CentralLogger + var distributedLoggerRecords = new List(); + bool distributedFileLogger = true; + string[] fileLoggerParameters = null; + + MSBuildApp.ProcessDistributedFileLogger( + distributedFileLogger, + fileLoggerParameters, + distributedLoggerRecords); + + // Verify that we have a distributed logger record with null central logger + distributedLoggerRecords.Count.ShouldBe(1); + distributedLoggerRecords[0].CentralLogger.ShouldBeNull(); + + // This should not throw ArgumentNullException when creating ProjectCollection + // The fix filters out null central loggers from the evaluationLoggers array + var loggers = Array.Empty(); + Should.NotThrow(() => + { + using var projectCollection = new ProjectCollection( + new Dictionary(), + loggers: [.. loggers, .. distributedLoggerRecords.Select(d => d.CentralLogger).Where(l => l is not null)], + remoteLoggers: null, + toolsetDefinitionLocations: ToolsetDefinitionLocations.Default, + maxNodeCount: 1, + onlyLogCriticalEvents: false, + loadProjectsReadOnly: true); + }); + } #endregion #region ProcessConsoleLoggerSwitches diff --git a/src/MSBuild/XMake.cs b/src/MSBuild/XMake.cs index 0bc9bd7aafd..181ae78179a 100644 --- a/src/MSBuild/XMake.cs +++ b/src/MSBuild/XMake.cs @@ -1392,8 +1392,8 @@ internal static bool BuildProject( // all of the loggers that are single-node only .. loggers, // all of the central loggers for multi-node systems. These need to be resilient to multiple calls - // to Initialize - .. distributedLoggerRecords.Select(d => d.CentralLogger) + // to Initialize. Filter out null loggers (e.g., DistributedFileLogger uses null central logger). + .. distributedLoggerRecords.Select(d => d.CentralLogger).Where(l => l is not null) ]; projectCollection = new ProjectCollection( From 46c82d96492349e177a281c12acd7d67989d8f47 Mon Sep 17 00:00:00 2001 From: YuliiaKovalova <95473390+YuliiaKovalova@users.noreply.github.com> Date: Fri, 16 Jan 2026 10:17:12 +0100 Subject: [PATCH 3/4] Update VersionPrefix to 18.3.1 --- eng/Versions.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Versions.props b/eng/Versions.props index 5ab5660455d..4ce8e50e5cc 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -3,7 +3,7 @@ - 18.3.0 + 18.3.1 preview 18.0.2 15.1.0.0 From 907ce02634ef1fd863ff6b957a8f2231342cfc17 Mon Sep 17 00:00:00 2001 From: YuliiaKovalova <95473390+YuliiaKovalova@users.noreply.github.com> Date: Mon, 19 Jan 2026 10:32:33 +0100 Subject: [PATCH 4/4] Update VersionPrefix from 18.3.1 to 18.3.0 --- eng/Versions.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Versions.props b/eng/Versions.props index 4ce8e50e5cc..5ab5660455d 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -3,7 +3,7 @@ - 18.3.1 + 18.3.0 preview 18.0.2 15.1.0.0