Skip to content

Binlog File Format

Kirill Osenkov edited this page Nov 24, 2023 · 1 revision

A binlog file is a DeflateStream compressed binary stream of records. Each record is a serialized BuildEventArgs object, a string, a name-value list or a binary blob (containing a .zip file with archived embedded files).

This is the hierarchy of BuildEventArgs classes: https://github.com/dotnet/msbuild/blob/7b37a280a13c01bbaeeb39b9c018a5ac7a728898/src/Build/Logging/BinaryLogger/BuildEventArgsWriter.cs#L145-L178 The event args objects are serialized and deserialized using BuildEventArgsWriter.

Each record starts with a byte that is the record kind, 0 indicating the end of the stream. A string record is the length of the string and then the UTF-8 encoded string. A name-value list is an array of string pairs (like an item's metadata or project's properties). Strings and name-value lists are deduplicated. Once a string is encountered in the stream, it is assigned an index, and subsequent records can refer to this string by index. Same for name-value lists.

BuildEventArgsReader is responsible for reading the .binlog file records and outputs a sequence of deserialized BuildEventArgs objects, as well as the embedded archive files blob. Consumers such as the binlog viewer read the record sequence and construct a tree of Object Model class instances modeling the build events.

Sources and additional links: