Build Perf Diagnostics logo

Build Perf Diagnostics

OrganizationPopular
dotnet
build-perf-diagnostics

Diagnose MSBuild build performance bottlenecks using binary log analysis. USE FOR: identifying why builds are slow by analyzing binlog performance summaries, detecting ResolveAssemblyReference (RAR) taking >5s, Roslyn analyzers consuming >30% of Csc time, single targets dominating >50% of build time, node utilization below 80%, excessive Copy tasks, NuGet restore running every build. Covers timeline analysis, Target/Task Performance Summary interpretation, and 7 common bottleneck categories. Use after build-perf-baseline has established measurements. DO NOT USE FOR: establishing initial baselines (use build-perf-baseline first), fixing incremental build issues (use incremental-build), parallelism tuning (use build-parallelism), non-MSBuild build systems.

Overview

Publisherdotnet
Repositoryskills
Skill namebuild-perf-diagnostics
Stars
5.4K
Forks
416
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by dotnet on GitHub. Read the source before you install it.

Installation

Install the Build Perf Diagnostics AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/dotnet/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/plugins/dotnet-msbuild/skills/build-perf-diagnostics .claude/skills/build-perf-diagnostics
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Build Perf Diagnostics in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Build Perf Diagnostics on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Build Perf Diagnostics is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Performance Analysis Methodology

  1. Generate a binlog: dotnet build /bl:{} -m
  2. Use the binlog MCP server (Microsoft.AITools.BinlogMcp, exposed under the binlog MCP namespace) which is bundled with this plugin

Alternate flow when MCP is unavailable: binlog replay to text logs

  1. Generate a binlog: dotnet build /bl:{} -m
  2. Replay to diagnostic log with performance summary:
    bash
    dotnet msbuild build.binlog -noconlog -fl -flp:v=diag;logfile=full.log;performancesummary
  3. Read the performance summary (at the end of full.log):
    bash
    grep "Target Performance Summary\|Task Performance Summary" -A 50 full.log
  4. Find expensive targets and tasks: The PerformanceSummary section lists all targets/tasks sorted by cumulative time
  5. Check for node utilization: grep for scheduling and node messages
    bash
    grep -i "node.*assigned\|building with\|scheduler" full.log | head -30
  6. Check analyzers: grep for analyzer timing
    bash
    grep -i "analyzer.*elapsed\|Total analyzer execution time\|CompilerAnalyzerDriver" full.log

Key Metrics and Thresholds

  • Build duration: what's "normal" — small project <10s, medium <60s, large <5min
  • Node utilization: ideal is >80% active time across nodes. Low utilization = serialization bottleneck
  • Single target domination: if one target is >50% of build time, investigate
  • Analyzer time vs compile time: analyzers should be <30% of Csc task time. If higher, consider removing expensive analyzers
  • RAR time: ResolveAssemblyReference >5s is concerning. >15s is pathological

Common Bottlenecks

1. ResolveAssemblyReference (RAR) Slowness

  • Symptoms: RAR taking >5s per project
  • Root causes: too many assembly references, network-based reference paths, large assembly search paths
  • Fixes: reduce reference count, use <DesignTimeBuild>false</DesignTimeBuild> for RAR-heavy analysis, set <ResolveAssemblyReferencesSilent>true</ResolveAssemblyReferencesSilent> for diagnostic
  • Advanced: <DesignTimeBuild> and <ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
  • Key insight: RAR runs unconditionally even on incremental builds because users may have installed targeting packs or GACed assemblies (see dotnet/msbuild#2015). With .NET Core micro-assemblies, the reference count is often very high.
  • Reduce transitive references: Set <DisableTransitiveProjectReferences>true</DisableTransitiveProjectReferences> to avoid pulling in the full transitive closure (note: projects may need to add direct references for any types they consume). Use ReferenceOutputAssembly="false" on ProjectReferences that are only needed at build time (not API surface). Trim unused PackageReferences.

2. Roslyn Analyzers and Source Generators

  • Symptoms: Csc task takes much longer than expected for file count (>2× clean compile time)
  • Diagnosis: Check the Task Performance Summary in the replayed log for Csc task time; grep for analyzer timing messages; compare Csc duration with and without analyzers (/p:RunAnalyzers=false)
  • Fixes:
    • Conditionally disable in dev: <RunAnalyzers Condition="'$(ContinuousIntegrationBuild)' != 'true'">false</RunAnalyzers>
    • Per-configuration: <RunAnalyzers Condition="'$(Configuration)' == 'Debug'">false</RunAnalyzers>
    • Code-style only: <EnforceCodeStyleInBuild Condition="'$(ContinuousIntegrationBuild)' == 'true'">true</EnforceCodeStyleInBuild>
    • Remove genuinely redundant analyzers from inner loop
    • Severity config in .editorconfig for less critical rules
  • Key principle: Preserve analyzer enforcement in CI. Never just "remove" analyzers — configure them conditionally.
  • GlobalPackageReference: Analyzers added via GlobalPackageReference in Directory.Packages.props apply to ALL projects. Consider if test projects need the same analyzer set as production code.
  • EnforceCodeStyleInBuild: When set to true in Directory.Build.props, forces code-style analysis on every build. Should be conditional on CI environment (ContinuousIntegrationBuild) to avoid slowing dev inner loop.

3. Serialization Bottlenecks (Single-threaded targets)

  • Symptoms: Performance summary shows most build time concentrated in a single project; diagnostic log shows idle nodes while one works
  • Common culprits: targets without proper dependency declaration, single project on critical path
  • Fixes: split large projects, optimize the critical path project, ensure proper BuildInParallel

4. Excessive File I/O (Copy tasks)

  • Symptoms: Copy task shows high aggregate time
  • Root causes: copying thousands of files, copying across network drives, Copy task unintentionally running once per item (per-file) instead of as a single batch (see dotnet/msbuild#12884)
  • Fixes: use hardlinks (<CreateHardLinksForCopyFilesToOutputDirectoryIfPossible>true</CreateHardLinksForCopyFilesToOutputDirectoryIfPossible>), reduce CopyToOutputDirectory items, use <UseCommonOutputDirectory>true</UseCommonOutputDirectory> when appropriate, set <SkipCopyUnchangedFiles>true</SkipCopyUnchangedFiles>, consider --artifacts-path (.NET 8+) for centralized output layout
  • Dev Drive: On Windows, switching to a Dev Drive (ReFS with copy-on-write and reduced Defender scans) can significantly reduce file I/O overhead for Copy-heavy builds. Recommend for both dev machines and self-hosted CI agents.

5. Evaluation Overhead

  • Symptoms: build starts slow before any compilation
  • Root causes: complex Directory.Build.props, wildcard globs scanning large directories, NuGetSdkResolver overhead (adds 180-400ms per project evaluation even when restored — see dotnet/msbuild#4025)
  • Fixes: reduce Directory.Build.props complexity, use <EnableDefaultItems>false</EnableDefaultItems> for legacy projects with explicit file lists, avoid NuGet-based SDK resolvers if possible
  • See: eval-performance skill for detailed guidance

6. NuGet Restore in Build

  • Symptoms: restore runs every build even when unnecessary
  • Fixes:
    • Separate restore from build: dotnet restore then dotnet build --no-restore
    • Enable static graph evaluation: <RestoreUseStaticGraphEvaluation>true</RestoreUseStaticGraphEvaluation> in Directory.Build.props — can save significant time in large builds (results are workload-dependent)

7. Large Project Count and Graph Shape

  • Symptoms: many small projects, each takes minimal time but overhead adds up; deep dependency chains serialize the build
  • Consider: project consolidation, or use /graph mode for better scheduling
  • Graph shape matters: a wide dependency graph (few levels, many parallel branches) builds faster than a deep one (many levels, serialized). Refactoring from deep to wide can yield significant improvements in both clean and incremental build times.
  • Actions: look for unnecessary project dependencies, consider splitting a bottleneck project into two, or merging small leaf projects

Using Binlog Replay for Performance Analysis

Step-by-step workflow using text log replay:

  1. Replay with performance summary:
    bash
    dotnet msbuild build.binlog -noconlog -fl -flp:v=diag;logfile=full.log;performancesummary
  2. Read target/task performance summaries (at the end of full.log):
    bash
    grep "Target Performance Summary\|Task Performance Summary" -A 50 full.log
    This shows all targets and tasks sorted by cumulative time — equivalent to finding expensive targets/tasks.
  3. Find per-project build times:
    bash
    grep "done building project\|Project Performance Summary" full.log
  4. Check parallelism (multi-node scheduling):
    bash
    grep -i "node.*assigned\|RequiresLeadingNewline\|Building with" full.log | head -30
  5. Check analyzer overhead:
    bash
    grep -i "Total analyzer execution time\|analyzer.*elapsed\|CompilerAnalyzerDriver" full.log
  6. Drill into a specific slow target:
    bash
    grep 'Target "CoreCompile"\|Target "ResolveAssemblyReferences"' full.log

Quick Wins Checklist

  • Use /maxcpucount (or -m) for parallel builds
  • Separate restore from build (dotnet restore then dotnet build --no-restore)
  • Enable static graph restore (<RestoreUseStaticGraphEvaluation>true</RestoreUseStaticGraphEvaluation>)
  • Enable hardlinks for Copy (<CreateHardLinksForCopyFilesToOutputDirectoryIfPossible>true</CreateHardLinksForCopyFilesToOutputDirectoryIfPossible>)
  • Disable analyzers conditionally in dev inner loop: <RunAnalyzers Condition="'$(ContinuousIntegrationBuild)' != 'true'">false</RunAnalyzers>
  • Enable reference assemblies (<ProduceReferenceAssembly>true</ProduceReferenceAssembly>)
  • Check for broken incremental builds (see incremental-build skill)
  • Check for bin/obj clashes (see check-bin-obj-clash skill)
  • Use graph build (/graph) for multi-project solutions
  • Use --artifacts-path (.NET 8+) for centralized output layout
  • Enable Dev Drive (ReFS) on Windows dev machines and self-hosted CI

Impact Categorization

When reporting findings, categorize by impact to help prioritize fixes:

  • 🔴 HIGH IMPACT (do first): Items consuming >10% of total build time, or a single target >50% of build time
  • 🟡 MEDIUM IMPACT: Items consuming 2-10% of build time
  • 🟢 QUICK WINS: Easy changes with modest impact (e.g., property flags in Directory.Build.props)

Frequently asked questions

What does the Build Perf Diagnostics AI skill do?

Diagnose MSBuild build performance bottlenecks using binary log analysis. USE FOR: identifying why builds are slow by analyzing binlog performance summaries, detecting ResolveAssemblyReference (RAR) taking >5s, Roslyn analyzers consuming >30% of Csc time, single targets dominating >50% of build time, node utilization below 80%, excessive Copy tasks, NuGet restore running every build. Covers timeline analysis, Target/Task Performance Summary interpretation, and 7 common bottleneck categories. Use after build-perf-baseline has established measurements. DO NOT USE FOR: establishing initial bas...

Why use Build Perf Diagnostics on TypingMind?

Because you install it once and use it with any model. Build Perf Diagnostics is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Build Perf Diagnostics in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/dotnet/skills/tree/main/plugins/dotnet-msbuild/skills/build-perf-diagnostics. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Build Perf Diagnostics?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Build Perf Diagnostics?

As many as you like. As long as a model supports skills, you can use Build Perf Diagnostics with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Build Perf Diagnostics AI skill free?

Yes. It is published on GitHub by dotnet under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇