用途:帮助诊断和优化 MSBuild 增量构建,解决“后续构建变慢”“什么都没改却重新构建”等问题。
主要能力:解释增量机制——带 Inputs/Outputs 的目标会比较文件时间戳,所有输出比输入新则跳过;无 Inputs/Outputs 的目标每次运行;Incremental="false" 强制运行;比较基于时间戳而非内容哈希,touch 文件会触发重建。列出增量失效常见原因:自定义目标缺少 Inputs/Outputs、输出路径含易变值(时间戳、GUID)、写入未登记的输出、缺少 FileWrites 注册、通配符或属性变化、NuGet 包更新、VBCSCompiler 缓存失效。
诊断用法:连续两次构建生成 binlog(dotnet build /bl:first.binlog、dotnet build /bl:second.binlog),分析第二次。优先用 binlog MCP(Microsoft.AITools.BinlogMcp)的 overview、search、target_reasons、project_targets、expensive_targets 工具;不可用时回放文本日志:dotnet msbuild second.binlog -noconlog -fl -flp:v=diag;logfile=second-full.log;performancesummary,再搜索“Building target”“is newer than output”等消息。可用 /clp:PerformanceSummary 看耗时目标,/pp:preprocess.xml 查看展开后的项目。
其他要点:用 FileWrites 注册生成文件以便 dotnet clean 清理,共享文件用 FileWritesShareable;Visual Studio 的 FUTDC 独立于 MSBuild,可用 DisableFastUpToDateCheck 关闭并开启详细日志;自定义目标应包含 Inputs(含项目文件与源文件)、稳定 Outputs(用 IntermediateOutputPath)、BeforeTargets 与 FileWrites 注册;仅需传递项而不影响增量时用 Returns 代替 Outputs。
限制:资料未提供该技能的安装方式、收费、平台支持范围及具体版本要求。