Open
Description
Since migrating our project from .NET 8 to .NET 9 and updating the MSBuild.StructuredLogger NuGet package from version 2.2.356 to 2.2.386, we frequently encounter an exception at BinaryLog.ReadBuild()
. Below is the stack trace:
System.AggregateException: One or more errors occurred. (Unable to sort because the IComparer.Compare() method returns inconsistent results. Either a value does not compare equal to itself, or one value repeatedly compared to another value yields different results. IComparer: ''.)
---> System.ArgumentException: Unable to sort because the IComparer.Compare() method returns inconsistent results. Either a value does not compare equal to itself, or one value repeatedly compared to another value yields different results. IComparer: ''.
at System.Collections.Generic.GenericArraySortHelper`2.Sort(Span`1 keys, Span`1 values, IComparer`1 comparer)
at Microsoft.Build.Collections.ArrayDictionary`2.Sort() in C:\MSBuildStructuredLog\src\StructuredLogger\BinaryLogger\ArrayDictionary.cs:line 223
at Microsoft.Build.Logging.StructuredLogger.Construction.AddPropertiesSorted(Folder propertiesFolder, TreeNode project, IEnumerable properties) in C:\MSBuildStructuredLog\src\StructuredLogger\Construction\Construction.cs:line 1163
at Microsoft.Build.Logging.StructuredLogger.Construction.<>c__DisplayClass37_0.<StatusEventRaised>g__AddGlobalProperties|2() in C:\MSBuildStructuredLog\src\StructuredLogger\Construction\Construction.cs:line 583
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Microsoft.Build.Logging.StructuredLogger.Build.WaitForBackgroundTasks() in C:\MSBuildStructuredLog\src\StructuredLogger\ObjectModel\Build.cs:line 285
at Microsoft.Build.Logging.StructuredLogger.BinaryLog.ReadBuild(Stream stream, Progress progress, Byte[] projectImportsArchive, ReaderSettings readerSettings) in C:\MSBuildStructuredLog\src\StructuredLogger\BinaryLog.cs:line 164
at Microsoft.Build.Logging.StructuredLogger.BinaryLog.ReadBuild(String filePath, Progress progress, ReaderSettings readerSettings) in C:\MSBuildStructuredLog\src\StructuredLogger\BinaryLog.cs:line 46
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at XXX.DevOps.Butler.Core.Jobs.FireAndForget.BuildAnalysisJob.ReadBinaryLogAsync(String binLogFilePath, CancellationToken cancellationToken) in D:\55\s\src\XXX.DevOps.Butler.Core\Jobs\FireAndForget\BuildAnalysisJob.cs:line 125
at XXX.DevOps.Butler.Core.Jobs.FireAndForget.BuildAnalysisJob.CreateBuildAnalysisEntityAsync(Build build, Timeline timeline, String binaryLogFilePath, PerformContext context, CancellationToken cancellationToken) in D:\55\s\src\XXX.DevOps.Butler.Core\Jobs\FireAndForget\BuildAnalysisJob.cs:line 78
at XXX.DevOps.Butler.Core.Jobs.FireAndForget.BuildAnalysisJob.ExecuteAsync(Int32 id, PerformContext context, CancellationToken cancellationToken) in D:\55\s\src\XXX.DevOps.Butler.Core\Jobs\FireAndForget\BuildAnalysisJob.cs:line 44
at InvokeStub_TaskAwaiter.GetResult(Object, Object, IntPtr*)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
Since we are using Hangfire, we can rerun a job if it fails. If we encounter the aforementioned exception, the reruns almost always succeed.
Metadata
Metadata
Assignees
Labels
No labels