KirillOsenkov / MSBuildStructuredLog

A logger for MSBuild that records a structured representation of executed targets, tasks, property and item values.
MIT License
1.45k stars 196 forks source link

NullReferenceException in viewer UI #662

Closed layomia closed 1 year ago

layomia commented 1 year ago

I was working on new targets in the dotnet/runtime repo (https://github.com/dotnet/runtime/pull/82179/commits/490c00d71f11c145e74280621fb8c2915d855543) and noticed that the viewer was showing a null ref when I opened the binlog produced when building my project. I was using a recent nightly build of the .NET 8 sdk (8.0.100-preview.3.23156.3-win-x64) and the latest version of the viewer (2.1.787). cc @ericstj

msbuild.zip

ericstj commented 1 year ago

Callstack of NRE:

System.NullReferenceException: Object reference not set to an instance of an object.

   at Microsoft.Build.Logging.StructuredLogger.MessageProcessor.Process(BuildMessageEventArgs args) in C:\src\KirillOsenkov\MSBuildStructuredLog\src\StructuredLogger\Construction\MessageProcessor.cs:line 50

   at Microsoft.Build.Logging.StructuredLogger.Construction.MessageRaised(Object sender, BuildMessageEventArgs args) in C:\src\KirillOsenkov\MSBuildStructuredLog\src\StructuredLogger\Construction\Construction.cs:line 455

https://github.com/KirillOsenkov/MSBuildStructuredLog/blob/512f69518c40347e5a3dd87e5999aa96984b8de5/src/StructuredLogger/Construction/MessageProcessor.cs#L50

It would seem that BuildEventContext here is null.

KirillOsenkov commented 1 year ago

can you email me the binlog?

KirillOsenkov commented 1 year ago

Oops, never mind, I was on the phone and didn't see it.

KirillOsenkov commented 1 year ago

I will publish the fix soon and will discuss with the MSBuild team, I feel like they should not be logging a message with a null BuildEventContext.

rainersigwald commented 1 year ago

Indeed we shouldn't have been: https://github.com/dotnet/msbuild/pull/8509.