Fix MSB1025 error when using DistributedFileLogger (-dfl flag)#13036
Fix MSB1025 error when using DistributedFileLogger (-dfl flag)#13036YuliiaKovalova merged 2 commits intomainfrom
Conversation
|
Hello @@copilot, I noticed that you’re changing an .swr file or any file under src/Package/MSBuild.VSSetup.. Please make sure to validate this change by an experimental VS insertion. This is accomplished by pushing to an exp/* branch, which requires write permissions to this repo. |
|
@copilot try again |
|
@copilot please try again, let's see if I have permissions. |
…logger Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com>
Done! The fix has been implemented in commit dcdf256. The issue was that when using I've also added a regression test |
baronfel
left a comment
There was a problem hiding this comment.
This LGTM, but I have to point out that we would not have shipped this bug if xmake.cs was nullable-enabled.
|
/backport to vs18.0 |
|
Started backporting to |
|
/backport to vs18.3 |
|
Started backporting to |
Summary
Fixes the MSB1025 ArgumentNullException error that occurs when using the
-dfl(distributed file logger) flag with MSBuild 18. The issue was introduced in PR #12095 where distributed logger central loggers were passed to ProjectCollection without filtering out null values.Customer Impact
Users running
msbuild -dflon MSBuild 18/VS 2026 encounter a blocking error:This prevents builds from running when using the distributed file logger, which is commonly used for multi-node build logging. The
-dflflag worked correctly in MSBuild 17 and earlier versions.Root Cause: When using
-dfl, the DistributedLoggerRecord intentionally has a null CentralLogger (as documented in XMake.cs line 4298-4299). PR #12095 introduced code that includes these central loggers in the evaluationLoggers array without filtering nulls, causing ProjectCollection.RegisterLoggerInternal() to throw ArgumentNullException.Regression?
Testing
Code Changes:
.Where(l => l is not null)to filter out null central loggers from the evaluationLoggers arrayTestNullCentralLoggerInDistributedLoggerRecordto verify DistributedLoggerRecords with null CentralLogger don't cause exceptionsVerification:
TestNullCentralLoggerInDistributedLoggerRecordpassesmsbuild simple.proj -dfl -t:Buildnow works correctly and creates distributed log fileRisk
Low - This is a minimal, surgical fix that:
Original prompt
This section details on the original issue you should resolve
<issue_title>MsBuild 18/VS 2026 MSB1025 error when using DistributedFileLogger - The 'logger' parameter cannot be null.</issue_title>
<issue_description>### Issue Description
When running
msbuild -dfli receive such errorMSBUILD : error MSB1025: podczas uruchamiania programu MSBuild wystąpił błąd wewnętrzny. System.ArgumentNullException: Parametr „logger” nie może być zerowy. w Microsoft.Build.Shared.ErrorUtilities.ThrowArgumentNull(String parameterName, String resourceName) w Microsoft.Build.Evaluation.ProjectCollection.RegisterLoggerInternal(ILogger logger) w Microsoft.Build.Evaluation.ProjectCollection.RegisterLoggers(IEnumerable1 loggers)w Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary
2 globalProperties, IEnumerable1 loggers, IEnumerable1 remoteLoggers, ToolsetDefinitionLocations toolsetDefinitionLocations, Int32 maxNodeCount, Boolean onlyLogCriticalEvents, Boolean loadProjectsReadOnly, Boolean useAsynchronousLogging, Boolean reuseProjectRootElementCache, Boolean enableTargetOutputLogging) w Microsoft.Build.CommandLine.MSBuildApp.BuildProject(String projectFile, String[] targets, String toolsVersion, Dictionary2 globalProperties, Dictionary2 restoreProperties, ILogger[] loggers, LoggerVerbosity verbosity, DistributedLoggerRecord[] distributedLoggerRecords, Boolean needToValidateProject, String schemaFile, Int32 cpuCount, Boolean multiThreaded, Boolean enableNodeReuse, TextWriter preprocessWriter, TextWriter targetsWriter, Boolean detailedSummary, ISet1 warningsAsErrors, ISet1 warningsNotAsErrors, ISet1 warningsAsMessages, Boolean enableRestore, ProfilerLogger profilerLogger, Boolean enableProfiler, Boolean interactive, ProjectIsolationMode isolateProjects, GraphBuildOptions graphBuildOptions, Boolean lowPriority, Boolean question, Boolean isTaskAndTargetItemLoggingRequired, Boolean isBuildCheckEnabled, String[] inputResultsCaches, String outputResultsCache, Boolean saveProjectResult, BuildResult& result, Boolean reportFileAccesses, String commandLine)w Microsoft.Build.CommandLine.MSBuildApp.Execute(String commandLine)`
Steps to Reproduce
to reproduce i create simple .net framework console solution and i run
msbuild -dflin solution directoryExpected Behavior
Solution should build as in previous version of msbuild (17)
Actual Behavior
Blocking error
MSBUILD : error MSB1025: podczas uruchamiania programu MSBuild wystąpił błąd wewnętrzny. System.ArgumentNullException: Parametr „logger” nie może być zerowy.Analysis
I tried to find any information in documentation about breaking changes in DistributedFileLogger but with no success.
Trying different fileLoggerParameters did not help
Switching to fileLogger works as expected
Versions & Configurations
Wersja programu MSBuild 18.0.5+e22287bf1 dla .NET Framework
18.0.5.56406
ran from C:\Program Files\Microsoft Visual Studio\18\Professional\MSBuild\Current\Bin\amd64\MSBuild.rsp
and
C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\MSBuild\Current\Bin\amd64\MSBuild.rsp
Windows 11 </issue_description>
<agent_instructions>Yes, this bug is very likely caused by the change in PR #12095.
Here's the problematic code introduced in src/MSBuild/XMake.cs:
csharpILogger[] evaluationLoggers =
[
// 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)
];
projectCollection = new ProjectCollection(
globalProperties,
evaluationLoggers, // <-- now includes distributed logger central loggers
...
The problem: When you use -dfl (distributed file logger), the DistributedLoggerRecord.CentralLogger can be null. The code now blindly passes all CentralLogger values into the ProjectCollection constructor without filtering out nulls.
When ProjectCollection.RegisterLoggers() iterates over these loggers and calls RegisterLoggerInternal(), it hits:
csharpprivate void RegisterLoggerInternal(ILogger logger)
{
ErrorUtilities.VerifyThrowArgumentNull(logger); // <-- throws here when logger is null
...
}
The fix should filter out null loggers:
csharpILogger[] evaluationLoggers =
[
.. loggers,
.. distributedLoggerRecords
.Select(d => d.CentralLogger)
.Where(l => l != null) // <-- add this filter
];</agent_instructions>
Comments on the Issue (you are @copilot in this section)
@YuliiaKovalova Hi @kkapuscinski ,Thank you for reporting the issue! It's likely to connected to #12095 change.
We are working on the fix.
cc: @baronfel </comment_new>
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.