build-parallelism
できること
このスキルは、複数のプロジェクトを持つソリューションやビルドファイルを分析し、余っているプロセッサーのコアがあるのに、なぜビルドが遅いのかを調べます。大きな.NETのソリューションでビルドが遅いのに悩む開発者のためのものです。
使う場面
- ✓ソリューションのビルドが遅く、マシンの作業者が遊んでいるとき。
- ✓並列の作業者を増やしても、ビルドが速くならないとき。
- ✓プロジェクトの参照が長い連鎖になり、ビルドの速さを制限しているとき。
スキルのリンク
https://github.com/dotnet/skills/blob/main/plugins/dotnet-msbuild/skills/build-parallelism/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“マシンには多くのコアがあるのに、私のソリューションのビルドが遅いです。原因を見つけて、何を変えるべきかを教えてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントはビルドのログを取得し、依存するプロジェクトの最も長い連鎖を見つけ、不要なプロジェクトの参照を取り除くなどの変更を勧めます。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Diagnose a slow parallel build (start here)
Work this checklist in order — it targets the usual root cause (a serial dependency chain that no number of cores can parallelize):
- Check how many worker nodes actually built the solution. Capture a
binlog with
dotnet build /bl:{}(PowerShell:dotnet build '-bl:{}') and inspect the node timeline to see whether more than one node ran. EverydotnetCLI command built on the SDK's MSBuild-forwarding path (build,msbuild,test,pack,publish, etc.) enables/maxcpucount(multiple nodes) by default;-m:1forces a single node. A directMSBuild.exeinvocation is sequential by default, so pass-mexplicitly to enable parallel worker nodes there. - Find the critical path. From the binlog, read per-project timings and the node timeline. If total build time ≈ the sum of the projects on one dependency chain, that chain — not CPU count — is the bottleneck.
- Name the chain explicitly, e.g.
Core → Api → Web → Tests. A long serial chain stays serial no matter how large-mis, because each project waits on its predecessor. - Look for unnecessary
ProjectReferenceedges that lengthen the chain — a reference that only needs build order (not the output assembly), or one that could be aPackageReference, forces serialization it doesn't need. - Recommend flattening: break false dependencies so independent projects
build concurrently, and consider
/graphfor better scheduling.
MSBuild Parallelism Model
/maxcpucount(or-m): number of worker nodes (processes)- Every
dotnetCLI command (build,msbuild,test,pack,publish, etc.) passes/maxcpucountby default via the SDK's shared MSBuild-forwarding path;-m:1overrides it with one node - A direct
MSBuild.exeinvocation is sequential by default and requires an explicit-m - Recommended:
-mwithout a number = use all logical processors - Each node builds one project at a time
- Projects are scheduled based on dependency graph
Project Dependency Graph
- MSBuild builds projects in dependency order (topological sort)
- Critical path: longest chain of dependent projects determines minimum build time
- Bottleneck: if project A depends on B, C, D and B takes 60s while C and D take 5s, B is the bottleneck
- Diagnosis: replay binlog to diagnostic log with
performancesummaryand check Project Performance Summary — shows per-project time; grep fornode.*assignedto check scheduling - Wide graphs (many independent projects) parallelize well; deep graphs (long chains) don't
Graph Build Mode (/graph)
dotnet build /graphormsbuild /graph- What it changes: MSBuild constructs the full project dependency graph BEFORE building
- Benefits: better scheduling, avoids redundant evaluations, enables isolated builds
- Limitations: all projects must use
<ProjectReference>(no programmatic MSBuild task references) - When to use: large solutions with many projects, CI builds
- When NOT to use: projects that dynamically discover references at build time
Optimizing Project References
- Reduce a
<ProjectReference>only after proving it is unnecessary; a slow but valid dependency must stay in the graph - Use
<ProjectReference ... SkipGetTargetFrameworkProperties="true">to avoid extra evaluations <ProjectReference ... ReferenceOutputAssembly="false">for build-order-only dependencies- Consider if a ProjectReference should be a PackageReference instead (pre-built NuGet)
- Use
solution filters(.slnf) to build subsets of the solution
BuildInParallel
<MSBuild Projects="@(ProjectsToBuild)" BuildInParallel="true" />in custom targets- Without
BuildInParallel="true", MSBuild task batches projects sequentially - Ensure
/maxcpucount> 1 for this to have effect
Multi-threaded MSBuild Tasks
- Individual tasks can run multi-threaded within a single project build
- Tasks implementing
IMultiThreadableTaskcan run on multiple threads - Tasks must declare thread-safety via
[MSBuildMultiThreadableTask]
Analyzing Parallelism with Binlog
Primary: binlog MCP (preferred)
Use the binlog MCP server (Microsoft.AITools.BinlogMcp, exposed under the binlog MCP namespace):
- Use expensive_projects tool → find the slowest projects and compare individual vs total build time
- Use expensive_targets tool → find bottleneck targets
- Use project_target_times tool → drill into a sp
よくある質問
MSBuild以外のビルドにも使えますか?
いいえ。MSBuildベースのソリューションとプロジェクトファイルのためのものです。
コアを増やせば、遅い連鎖は直りますか?
通常は直りません。長い直列の連鎖は、コアを増やしても直列のままです。
プロジェクトを変えますか?
変更を勧めるだけで、確認の後にあなたが適用します。
詳細
作者による元の説明
Analyze an MSBuild solution, solution filter, or Build.proj that schedules multiple project files. USE FOR: measured idle worker nodes, `-m` that does not scale, a serial ProjectReference critical path, graph builds, or an MSBuild task that builds a Projects list. Requires at least two distinct project files whose scheduling or throughput must be analyzed. DO NOT USE for non-MSBuild build systems.
repo: dotnet/skills
人気
- GitHubのスター
- 5.8k
- ランキング
- #14592
- ライセンス
- MIT
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
create-custom-agent
5.8kVisual Studio Codeのカスタムエージェントのファイルを、独自のツール、指示、ほかのエージェントへの引き継ぎとともに作るようエージェントを支援します。
create-skill
5.8k有効な名前、明確な発動の説明、規格に従うSKILL.mdファイルを持つ、新しいエージェントのスキルを作るようエージェントを支援します。
csharp-scripts
5.8k.NETのコマンドラインツールを使って、完全なプロジェクトを作らずに、小さなC#のプログラムを一つのファイルとして実行するようエージェントを支援します。
dotnet-pinvoke
5.8k署名、文字列の扱い、メモリ、安全なハンドルを含めて、ネイティブのC言語またはC++のライブラリを.NETから正しく呼び出すようエージェントを支援します。
似ているスキル
openclaw-update
394k既存のOpenClaw Gatewayを更新するようエージェントを支援します。インストール方法に合った更新方法を選び、セッションを動かし続けます。
diagnose-gateway
394k設定、チャンネル、ポートを確認して、OpenClaw Gatewayが失敗している理由を、何も変更せずに突き止めるようエージェントを支援します。
crabbox-apps
394k一時的なクラウドマシン上でアプリを開いて実行し、そのビューをチャットのサイドパネルに表示するようエージェントを支援します。