Binlog Failure Analysis

作者 dotnet0608d8924cd3MIT5.5K 个星标收录于 2026年10月8日更新于 2026年10月8日仓库今天更新

Analyze MSBuild binary logs to diagnose build failures. USE FOR: build errors that are unclear from console output, diagnosing cascading failures across multi-project builds, tracing MSBuild target execution order, and generally any MSBuild build issues. Requires an existing .binlog file. DO NOT USE FOR: generating binlogs (use binlog-generation), non-MSBuild build systems.

AI 生成的概览

通过 MCP 工具或文本日志回放分析 .binlog 文件,诊断 MSBuild 生成失败。

功能
该技能指导智能体从已有的 .binlog 文件诊断 MSBuild 生成失败。首选流程通过 binlog MCP 服务器查询二进制日志,检查错误、警告、属性、项、项目评估数据、目标执行情况以及内嵌文件内容。当 MCP 服务器不可用时,回退到将 binlog 回放为诊断、错误和警告文本日志并对其进行搜索。它产出的是失败分析,而不是新的生成产物。
适用场景
适用于控制台输出无法说明的生成错误、多项目生成中的级联失败、追踪 MSBuild 目标执行顺序,以及其他 MSBuild 生成问题。它需要已有的 .binlog 文件,不用于生成 binlog,也不适用于非 MSBuild 生成系统。
运行要求
需要已有的 .binlog 文件。首选流程需要 binlog MCP 服务器(Microsoft.AITools.BinlogMcp,binlog MCP 命名空间);回退流程需要带 MSBuild 的 dotnet CLI 来回放 binlog,以及 grep 等 shell 工具来搜索文本日志。不附带脚本,仅为说明文档。

Analyzing MSBuild Failures with Binary Logs

This skill diagnoses MSBuild build failures from a .binlog file. The preferred path uses the binlog MCP server (Microsoft.AITools.BinlogMcp, exposed under the binlog MCP namespace) which is bundled with this plugin. If the MCP server is not available, fall back to the binlog replay workflow at the bottom.

Primary workflow — binlog MCP

The MCP server exposes structured tools for inspecting a .binlog without parsing text logs. Call them directly instead of replaying the binlog to a text file. Call tools/list for the MCP first if you are unsure which tools are available.

Important constraints:

  • The .binlog file is a binary format — do NOT try to cat, head, strings, or read it directly. Use only the MCP tools to query it.
  • The original source/project files might or might NOT be available on disk. Project files (.csproj, .props, .targets, App.config, etc.) - if you cannot locate them on disk, they can only be read from within the binlog via MCP tools (e.g., embedded/source file retrieval).
  • Synthesize findings as you go. Do not spend all available time investigating — once you have enough evidence, present your conclusions. A partial answer with clear reasoning is better than timing out mid-investigation.

Use the available MCP server tools to query the binary log for:

  • Build errors and warnings
  • MSBuild properties and their values
  • MSBuild items (PackageReference, ProjectReference, etc.)
  • Project evaluation data
  • Target execution details
  • File contents embedded in the binlog

Fallback workflow — text-log replay (when MCP is unavailable)

Use this only when the MCP server cannot be started (for example, on an older SDK or in an offline environment).

Replay the binlog to text logs

bash
dotnet msbuild build.binlog -noconlog \  -fl  "-flp:v=diag;logfile=full.log;performancesummary" \  -fl1 "-flp1:errorsonly;logfile=errors.log" \  -fl2 "-flp2:warningsonly;logfile=warnings.log"

PowerShell note: Use -flp:"v=diag;logfile=full.log;performancesummary" (quoted semicolons).

Search the text logs

bash
cat errors.loggrep -n -B2 -A2 "CS0246" full.loggrep -i "CoreCompile.*FAILED\|Build FAILED\|error MSB" full.loggrep 'Target "CoreCompile"' full.log | grep -oP 'project "[^"]*"'

Generating a binlog (only if none exists)

bash
dotnet build /bl:build.binlog

来源与署名

来源:dotnet/skills位于plugins/dotnet-msbuild/skills/binlog-failure-analysis提交0608d89

许可证: MIT

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架