用途:诊断并行构建缓慢问题,重点排查串行依赖链这一常见根因,而非单纯增加核心数。
主要能力:检查实际参与构建的工作节点数量;从 binlog 读取各项目耗时与节点时间线,找出关键路径并显式命名依赖链(如 Core → Api → Web → Tests);识别不必要的 ProjectReference 边;建议扁平化依赖、使用 /graph 改善调度;分析 BuildInParallel 与多线程任务;给出 CI/CD 并行建议。
用法要点:用 dotnet build /bl:{} 采集 binlog(PowerShell 写作 dotnet build '-bl:{}')。dotnet CLI 的 build、msbuild、test、pack、publish 等默认启用 /maxcpucount,-m:1 强制单节点;直接调用 MSBuild.exe 默认串行,需显式传 -m。推荐 -m 不带数字以使用全部逻辑处理器。图构建模式用 dotnet build /graph 或 msbuild /graph,要求所有项目使用 ProjectReference。可用 SkipGetTargetFrameworkProperties="true"、ReferenceOutputAssembly="false" 优化引用,或用 .slnf 构建子集。自定义目标中需 <MSBuild Projects="@(ProjectsToBuild)" BuildInParallel="true" /> 且 /maxcpucount > 1。
binlog 分析:优先使用 binlog MCP(Microsoft.AITools.BinlogMcp),含 expensive_projects、expensive_targets、project_target_times 工具。回退方案:dotnet msbuild build.binlog -noconlog -fl "-flp:v=diag;logfile=full.log;performancesummary",再查看 Project Performance Summary 与 Target Performance Summary。理想情况构建时间远小于各项目时间之和;若接近则说明串行依赖过多或存在阻塞项目。
限制:/graph 不适用于构建时动态发现引用的项目;减少 ProjectReference 前须先证明其不必要;资料未提供具体性能数字、收费或平台信息。