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 從公開儲存庫中收錄這些內容。

檢舉或申請下架