@@ -2294,6 +2294,44 @@ public void TestProcessFileLoggerSwitch5()
22942294 distributedLoggerRecords . Count . ShouldBe ( 0 ) ; // "Expected no distributed loggers to be attached"
22952295 loggers . Count . ShouldBe ( 0 ) ; // "Expected no central loggers to be attached"
22962296 }
2297+
2298+ /// <summary>
2299+ /// Verify that DistributedLoggerRecords with null CentralLogger don't cause exceptions when creating ProjectCollection
2300+ /// This is a regression test for the issue where -dfl flag caused MSB1025 error due to null logger not being filtered.
2301+ /// </summary>
2302+ [ Fact ]
2303+ public void TestNullCentralLoggerInDistributedLoggerRecord ( )
2304+ {
2305+ // Simulate the scenario when using -dfl flag
2306+ // ProcessDistributedFileLogger creates a DistributedLoggerRecord with null CentralLogger
2307+ var distributedLoggerRecords = new List < DistributedLoggerRecord > ( ) ;
2308+ bool distributedFileLogger = true ;
2309+ string [ ] fileLoggerParameters = null ;
2310+
2311+ MSBuildApp . ProcessDistributedFileLogger (
2312+ distributedFileLogger ,
2313+ fileLoggerParameters ,
2314+ distributedLoggerRecords ) ;
2315+
2316+ // Verify that we have a distributed logger record with null central logger
2317+ distributedLoggerRecords . Count . ShouldBe ( 1 ) ;
2318+ distributedLoggerRecords [ 0 ] . CentralLogger . ShouldBeNull ( ) ;
2319+
2320+ // This should not throw ArgumentNullException when creating ProjectCollection
2321+ // The fix filters out null central loggers from the evaluationLoggers array
2322+ var loggers = Array . Empty < ILogger > ( ) ;
2323+ Should . NotThrow ( ( ) =>
2324+ {
2325+ using var projectCollection = new ProjectCollection (
2326+ new Dictionary < string , string > ( ) ,
2327+ loggers : [ .. loggers , .. distributedLoggerRecords . Select ( d => d . CentralLogger ) . Where ( l => l is not null ) ] ,
2328+ remoteLoggers : null ,
2329+ toolsetDefinitionLocations : ToolsetDefinitionLocations . Default ,
2330+ maxNodeCount : 1 ,
2331+ onlyLogCriticalEvents : false ,
2332+ loadProjectsReadOnly : true ) ;
2333+ } ) ;
2334+ }
22972335 #endregion
22982336
22992337 #region ProcessConsoleLoggerSwitches
0 commit comments