• Stars
    star
    1,421
  • Rank 32,893 (Top 0.7 %)
  • Language
    C#
  • License
    MIT License
  • Created over 8 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A logger for MSBuild that records a structured representation of executed targets, tasks, property and item values.

MSBuildStructuredLog

A logger for MSBuild that records a structured representation of executed targets, tasks, property and item values. It can greatly simplify build investigations and provides a portable log interchange format (*.binlog) and a rich interactive log viewer app.

Build status NuGet package Chocolatey

Homepage: https://msbuildlog.com

View binlogs in the Browser: https://live.msbuildlog.com

Important: the NuGet package is now being published to https://nuget.org/packages/MSBuild.StructuredLogger (old location: https://nuget.org/packages/Microsoft.Build.Logging.StructuredLogger). Please update to use the new Package Id.

Thanks to SignPath.io for providing a free code signing service and to the SignPath Foundation for a free code signing certificate to sign the installer.

Install:

Install from https://msbuildlog.com.

The app updates automatically via Squirrel (after launch it checks for updates in background), next launch starts the newly downloaded latest version.

Screenshot1

Installing the Avalonia version on Mac:

There are a couple of extra steps to get the .app running on macOS since it's currently distributed as an unsigned application:

  1. In System Preferences -> Security & Privacy ensure Allow apps downloaded from: is set to App Store and identified developers.
  2. Download the Structured.Log.Viewer-x64.zip (if on Intel Mac) or Structured.Log.Viewer-arm64.zip (if on M1/ARM) from the latest Release.
  3. If necessary, unzip the file (Safari does this for you after downloading automatically).
  4. Move the StructuredLogViewer.app into your Applications folder.
  5. In terminal run: chmod +x /Applications/Structured\ Log\ Viewer.app/Contents/MacOS/StructuredLogViewer.Avalonia to give the app execution permissions
  6. On the first run, right click the app on Finder and select Open. You will be prompted that the app is not signed by a known developer. Click Open.

Building & Running the Avalonia version on Mac:

git clone https://github.com/KirillOsenkov/MSBuildStructuredLog
cd MSBuildStructuredLog
./run.sh

Alternatively, a longer version:

  1. dotnet build MSBuildStructuredLog.Avalonia.sln
  2. dotnet publish MSBuildStructuredLog.Avalonia.sln --self-contained -o <some_dir> (I used $HOME/tools/artifacts/StructuredLogViewer.Avalonia)
  3. make a script $HOME/bin/structured-log-viewer (or whatever's on your PATH):
#! /bin/sh
exec dotnet ${HOME}/tools/artifacts/StructuredLogViewer.Avalonia/publish/StructuredLogViewer.Avalonia.dll "$@"

Requirements:

Windows:

  • .NET Framework 4.7.2
  • MSBuild 16.0
  • Visual Studio 2019

Mac:

  • .NET 6 SDK

Usage:

Starting with MSBuild 15.3 you can pass the new /bl switch to msbuild.exe to record a binary build log to msbuild.binlog, in the same folder as the project/solution being built:

Screenshot

or you can build the solution or open an existing log file through the viewer app:

Screenshot2

Alternatively (useful for older versions of MSBuild) you can attach the logger to any MSBuild-based build using the logger library: StructuredLogger.dll. It is available in a NuGet package: https://www.nuget.org/packages/MSBuild.StructuredLogger

msbuild solution.sln /t:Rebuild /v:diag /noconlog /logger:BinaryLogger,%localappdata%\MSBuildStructuredLogViewer\app-2.1.596\StructuredLogger.dll;1.binlog

To use a portable version of the logger (e.g. with the dotnet msbuild command) you need a .NET Standard version of StructuredLogger.dll, not the .NET Framework (Desktop) version.

Download this NuGet package: https://www.nuget.org/packages/MSBuild.StructuredLogger/2.1.545 and inside it there's the lib\netstandard2.0\StructuredLogger.dll. Try passing that to dotnet build like this:

dotnet msbuild Some.sln /v:diag /nologo /logger:BinaryLogger,"packages\MSBuild.StructuredLogger.2.1.545\lib\netstandard2.0\StructuredLogger.dll";"C:\Users\SomeUser\Desktop\binarylog.binlog"

Read more about the log formats here: https://github.com/KirillOsenkov/MSBuildStructuredLog/wiki/Log-Format

Features:

  • Preprocess project files (with all imports inlined), right-click on a project -> Preprocess
  • If a log has embedded files, you can view the list of files, full-text search in all files, and use the Space key (or double-click) on most nodes to view the source code.
  • Displays double-writes (when files from different sources are written to the same destination during a build, thus causing non-determinism)
  • Displays target dependencies for each target
  • Narrow down the search results using the under() or project() clauses to only display results under a certain parent or project.
  • Each node in the tree has a context menu. Ctrl+C to copy an item and the entire subtree to Clipboard as text.
  • Delete to hide nodes from the tree (to get uninteresting stuff out of the way).
  • Open and save log files (option to save log files to .xml)
  • Logs can include the source code project files and all imported files used during the build.

Investigating problems with MSBuildStructuredLog

Open an issue if you're running into something weird and I can take a look into it. If MSBuildStructuredLog crashes during the build, it will attempt to write the exception call stack to:

%localappdata%\Microsoft\MSBuildStructuredLog\LoggerExceptions.txt

MSBuild Resources

More Repositories

1

SourceBrowser

Source browser website generator that powers http://referencesource.microsoft.com and http://sourceroslyn.io
C#
1,063
star
2

RoslynQuoter

Roslyn tool that for a given C# program shows syntax tree API calls to construct its syntax tree
C#
822
star
3

XmlParser

A Roslyn-inspired full-fidelity XML parser with no dependencies and a simple Visual Studio XML language service
C#
323
star
4

MetadataTools

Various tools and helpers to read assembly metadata.
C#
175
star
5

QuickInfo

http://quickinfo.io - a search textbox with extensible "answers" (calculator, unit-converter, colors, ascii/unicode, etc). See demo at http://quickinfo.io/?demo
C#
172
star
6

CodeCleanupTools

A set of command-line tools to cleanup C# and VB source code.
C#
123
star
7

Undo

Simple .NET Undo/Redo framework with merging and transactions
C#
102
star
8

ContentSync

Directory copy/sync/mirror tool that uses file contents (not timestamps) to avoid touching identical files
C#
64
star
9

LargeAddressAware

A build tools package that adds support for making 32-bit exes LARGEADDRESSAWARE
C#
51
star
10

StructuredEditor

An experimental structured code editor prototype for a subset of C#
C#
48
star
11

LayoutDesigner

A prototype Silverlight UI layout designer. Works with basic panels (StackPanel and Grid). Built entirely using drag-n-drop. XAML can be copied to clipboard. Built with Silverlight 4 and runs in the browser.
C#
48
star
12

LiveGeometry

Interactive geometry CAD-like educational software
Visual Basic 6.0
30
star
13

Bliki

Blog/Wiki/Notes
30
star
14

MathParser

Parser for arithmetic expressions
C#
21
star
15

MEFMetadata

Metadata-based part discovery for MEF, uses the Roslyn metadata reader and is faster than reflection.
C#
18
star
16

MSBuildLog

Source code for http://msbuildlog.com
HTML
16
star
17

NuGetTools

C#
16
star
18

dotfiles

My dotfiles and Mac config
Shell
13
star
19

Benchmarks

My collection of benchmarks for random pieces of code
C#
13
star
20

WpfSendKeys

SendKeys for WPF
C#
11
star
21

Misc

Various small and one-off projects just barely too big to throw away
C#
10
star
22

DumpTools

Tools to analyze managed .dmp files using ClrMd
C#
8
star
23

MEFTools

Tools to help working with MEF
C#
7
star
24

Dia2Dump

Taken from C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\DIA SDK\Samples\DIA2Dump
C++
6
star
25

MyOwnSearchEngine

This repo has moved to https://github.com/KirillOsenkov/QuickInfo
JavaScript
3
star
26

DiagnosticMargin

C#
3
star
27

VSInstanceFinder

Finds the locations of all installed VS 2017 instances
C#
2
star
28

ColorTools

JavaScript
2
star
29

MagicSquare

Simple addition/multiplication table for kids
C#
2
star
30

ApplyPatch

Simple utility to apply a patch to a set of files
C#
1
star
31

MefHost

Test MEF host to repro a bug
C#
1
star
32

guilabs

Source code for http://guilabs.net
HTML
1
star
33

BeachballPoker

C#
1
star