Skip to content

Can't read .binlog file in .NET 6 Preview 2 #6225

@jonathanpeppers

Description

@jonathanpeppers

Issue Description

We have some integration test code that fails to read .binlog files, such as:

var duration = TimeSpan.Zero;
using var fileStream = File.OpenRead("msbuild.binlog");
using var gzip = new GZipStream(fileStream, CompressionMode.Decompress);
using var binaryReader = new BinaryReader(gzip);
int fileFormatVersion = binaryReader.ReadInt32();
var buildReader = new BuildEventArgsReader(binaryReader, fileFormatVersion);
BuildEventArgs args;
var started = new Stack<DateTime>();
while ((args = buildReader.Read()) != null)
{
	if (args is ProjectStartedEventArgs projectStarted)
	{
		started.Push(projectStarted.Timestamp);
	}
	else if (args is ProjectFinishedEventArgs projectFinished)
	{
		duration += projectFinished.Timestamp - started.Pop();
	}
}

if (duration == TimeSpan.Zero)
	throw new InvalidDataException($"No project build duration found!");

There might be a way to clean up this code (let me know), but BuildEventArgsReader.Read() returns null on the first call.

This was working in .NET 6 Preview 1.

Steps to Reproduce

Try the example project, just build & run it in VS with the right .NET 6.0.100-preview.2.21114.3 installed:

msbuild-binlog.zip

This project attempts to parse a .binlog that was produced on my machine -- it was a build of a .NET 6 Android application. Both the sample project above and .binlog were using the same .NET version.

Expected Behavior

BuildEventArgsReader.Read() returns something.

Actual Behavior

BuildEventArgsReader.Read() returns null.

Versions & Configurations

Windows 10, using .NET 6.0.100-preview.2.21114.3

Installed from: https://dotnetcli.azureedge.net/dotnet/Sdk/6.0.100-preview.2.21114.3/dotnet-sdk-6.0.100-preview.2.21114.3-win-x64.exe

Attach a binlog

See the .zip above.

Metadata

Metadata

Assignees

Labels

bugneeds-triageHave yet to determine what bucket this goes in.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions