感謝 Vatsan Madhavan 小夥伴推薦的 MSBuild 輸出日誌可視化工具,這個工具可使用漂亮的 WPF 界面預覽 MSBuild 複雜的輸出內容git
這是一個徹底開源的工具,請看 KirillOsenkov/MSBuildStructuredLog: A logger for MSBuild that records a structured representation of executed targets, tasks, property and item values.github
這個工具的使用方法很簡單,首先是在項目裏面使用 MSBuild 命令加上 /bl
生成 msbuild.binlog
文件,如使用下面代碼工具
msbuild /bl
從官網 MSBuild Log Viewer 下載最新版本ui
打開軟件,將 msbuild.binlog
文件拖進去就能夠顯示日誌的信息日誌
另外這個工具還提供了 NuGet 庫能夠用來讀取 binlog 文件code
先安裝 MSBuild.StructuredLogger 庫,而後使用下面代碼blog
using System; using Microsoft.Build.Logging.StructuredLogger; class BinaryLogReadBuild { static void Main(string[] args) { string binLogFilePath = @"C:\temp\test.binlog"; var buildRoot = BinaryLog.ReadBuild(binLogFilePath); buildRoot.VisitAllChildren<CscTask>(c => Console.WriteLine(c.CommandLineArguments)); } }
這個軟件用到了特別漂亮的 TreeView 歡迎小夥伴抄樣式get