incremental-build
Guide for optimizing MSBuild incremental builds. USE FOR: builds slower than expected on subsequent runs, 'nothing changed but it rebuilds anyway', diagnosing why targets re-execute unnecessarily, fixing broken no-op builds.
Install / Use
npx skills add dotnet/skills --skill incremental-buildInstalls into whichever agent you are using.
SKILL.md
Installable skill definition
Quality Score
Category
Development & EngineeringSupported Platforms
Tags
Our assessment of incremental-build
incremental-build scores 87/100 on our quality scale, 867th of 2,398 Development & Engineering skills we index (top 37%).
Its SKILL.md is 14 KB long, well organised into 14 sections with 4 code examples: a thorough specification that gives an agent plenty to work with.
With 5,471 GitHub stars, it is one of the more widely adopted skills in the catalogue.
Maintenance, license and trust
- The repository was last updated 2 days ago, so incremental-build is actively maintained.
- It is released under the MIT license, a permissive license that allows use, modification and commercial use with attribution.
- Its trust signals score 100/100, with no cautions. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
incremental-build compared with similar skills
All 4 of these similar skills score higher than incremental-build; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| incremental-build (this skill)by dotnet | 87 | 5.5k | 2d ago | SKILL.md |
| ai-job-searchby MadsLorentzen | 100 | 44.0k | 5d ago | CLAUDE.md |
| claude-howtoby luongnv89 | 100 | 41.7k | today | CLAUDE.md |
| algorithmic-artby anthropics | 100 | 177.9k | 4d ago | SKILL.md |
| pptxby anthropics | 100 | 177.9k | 4d ago | SKILL.md |
Frequently asked questions
- How do I install incremental-build?
- Run
npx skills add dotnet/skills --skill incremental-build. The install tabs above show the steps for each supported agent. - Which AI agents does incremental-build work with?
- It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
- Is incremental-build safe to use?
- It is MIT-licensed and scores 100/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is incremental-build still maintained?
- The repository was last updated 2 days ago, so incremental-build is actively maintained.
Skill content
View source on GitHubname: incremental-build description: "Guide for optimizing MSBuild incremental builds. USE FOR: builds slower than expected on subsequent runs, 'nothing changed but it rebuilds anyway', diagnosing why targets re-execute unnecessarily, fixing broken no-op builds. Covers 8 common causes: missing Inputs/Outputs on custom targets, volatile properties in output paths (timestamps/GUIDs), file writes outside tracked Outputs, missing FileWrites registration, glob changes, Visual Studio Fast Up-to-Date Check (FUTDC) issues. Key diagnostic: look for 'Building target completely' vs 'Skipping target' in binlog. DO NOT USE FOR: first-time build slowness (use build-perf-baseline), parallelism issues (use build-parallelism), evaluation-phase slowness (use eval-performance), non-MSBuild build systems." license: MIT
How MSBuild Incremental Build Works
MSBuild's incremental build mechanism allows targets to be skipped when their outputs are already up to date, dramatically reducing build times on subsequent runs.
- Targets with
InputsandOutputsattributes: MSBuild compares the timestamps of all files listed inInputsagainst all files listed inOutputs. If every output file is newer than every input file, the target is skipped entirely. - Without
Inputs/Outputs: The target runs every time the build is invoked. This is the default behavior and the most common cause of slow incremental builds. Incrementalattribute on targets: Targets can explicitly opt in or out of incremental behavior. SettingIncremental="false"forces the target to always run, even ifInputsandOutputsare specified.- Timestamp-based comparison: MSBuild uses file system timestamps (last write time) to determine staleness. It does not use content hashes. This means touching a file (updating its timestamp without changing content) will trigger a rebuild.
<!-- This target is incremental: skipped if Output is newer than all Inputs -->
<Target Name="Transform"
Inputs="@(TransformFiles)"
Outputs="@(TransformFiles->'$(OutputPath)%(Filename).out')">
<!-- work here -->
</Target>
<!-- This target always runs because it has no Inputs/Outputs -->
<Target Name="PrintMessage">
<Message Text="This runs every build" />
</Target>
Why Incremental Builds Break (Top Causes)
-
Missing Inputs/Outputs on custom targets — Without both attributes, the target always runs. This is the single most common cause of unnecessary rebuilds.
-
Volatile properties in Outputs path — If the output path includes something that changes between builds (e.g., a timestamp, build number, or random GUID), MSBuild will never find the previous output and will always rebuild.
-
File writes outside of tracked Outputs — If a target writes files that aren't listed in its
Outputs, MSBuild doesn't know about them. The target may be skipped (because its declared outputs are up to date), but downstream targets may still be triggered. -
Missing FileWrites registration — Files created during the build but not registered in the
FileWritesitem group won't be cleaned bydotnet clean. Over time, stale files can confuse incremental checks. -
Glob changes — When you add or remove source files, the item set (e.g.,
@(Compile)) changes. Since these items feed intoInputs, the set of inputs changes and triggers a rebuild. This is expected behavior but can be surprising. -
Property changes — Properties that feed into
InputsorOutputspaths (e.g.,$(Configuration),$(TargetFramework)) will cause rebuilds when changed. Switching between Debug and Release is a full rebuild by design. -
NuGet package updates — Changing a package version updates
project.assets.jsonand potentially many resolved assembly paths. This changes the inputs toResolveAssemblyReferencesandCoreCompile, triggering a rebuild. -
Build server VBCSCompiler cache invalidation — The Roslyn compiler server (
VBCSCompiler) caches compilation state. If the server is recycled (timeout, crash, or manual kill), the next build may be slower even though MSBuild's incremental checks pass, because the compiler must repopulate its in-memory caches.
Diagnosing "Why Did This Rebuild?"
Use binary logs (binlogs) to understand exactly why targets ran instead of being skipped.
Step-by-step using binlog
- Build twice with binlogs to capture the incremental build behavior:
The first build establishes the baseline. The second build is the one you want to be incremental. Analyzedotnet build /bl:first.binlog dotnet build /bl:second.binlogsecond.binlog.
Primary: binlog MCP (preferred)
Use the binlog MCP server (Microsoft.AITools.BinlogMcp, exposed under the binlog MCP namespace) to analyze the second binlog:
- Use the overview tool to check overall build status and duration
- Use the search tool to find targets that executed vs were skipped — search for "Building target completely", "Building target incrementally", "Skipping target"
- Use the search tool to find "is newer than output" messages that reveal which input file triggered a rebuild
- Use target-related tools (target_reasons, project_targets) to inspect why specific targets ran
- Use the expensive_targets tool to find targets that consumed the most time in the second build — these are your optimization targets
Fallback: text-log replay (when MCP is unavailable)
-
Replay the second binlog to a diagnostic text log:
dotnet msbuild second.binlog -noconlog -fl -flp:v=diag;logfile=second-full.log;performancesummaryThen search for targets that actually executed:
grep 'Building target\|Target.*was not skipped' second-full.logIn a perfectly incremental build, most targets should be skipped.
-
Inspect non-skipped targets by looking for their execution messages in the diagnostic log. Check for "out of date" messages that indicate why a target ran.
-
Look for key messages in the binlog:
"Building target 'X' completely"— means MSBuild found no outputs or all outputs are missing; this is a full target execution."Building target 'X' incrementally"— means some (but not all) outputs are out of date."Skipping target 'X' because all output files are up-to-date"— target was correctly skipped.
-
Search for "is newer than output" messages to find the specific input file that triggered the rebuild:
grep "is newer than output" second-full.logThis reveals exactly which input file's timestamp caused MSBuild to consider the target out of date.
Additional diagnostic techniques
- Compare
first.binlogandsecond.binlogside by side in the MSBuild Structured Log Viewer to see what changed. - Use
grep 'Target Performance Summary' -A 30 second-full.logto see which targets consumed the most time in the second build — these are your optimization targets. - Check for targets with zero-duration that still ran — they may have unnecessary dependencies causing them to execute.
FileWrites and Clean Build
The FileWrites item group is MSBuild's mechanism for tracking files generated during the build. It powers dotnet clean and helps maintain correct incremental behavior.
FileWritesitem: Register any file your custom targets create so thatdotnet cleanknows to remove them. Without this, generated files accumulate across builds and may confuse incremental checks.FileWritesShareableitem: Use this for files that are shared across multiple projects (e.g., shared generated code). These files are tracked but not deleted if other projects still reference them.- If not registered: Files accumulate in the output and intermediate directories.
dotnet cleanwon't remove them, and they may cause stale data issues or confuse up-to-date checks.
Pattern for registering generated files
Add generated files to FileWrites inside the target that creates them:
<Target Name="MyGenerator" Inputs="..." Outputs="$(IntermediateOutputPath)generated.cs">
<!-- Generate the file -->
<WriteLinesToFile File="$(IntermediateOutputPath)generated.cs" Lines="@(GeneratedLines)" />
<!-- Register for clean -->
<ItemGroup>
<FileWrites Include="$(IntermediateOutputPath)generated.cs" />
</ItemGroup>
</Target>
Visual Studio Fast Up-to-Date Check
Visual Studio has its own up-to-date check (Fast Up-to-Date Check, or FUTDC) that is separate from MSBuild's Inputs/Outputs mechanism. Understanding the difference is critical for diagnosing "it rebuilds in VS but not on the command line" issues.
- VS FUTDC is faster because it runs in-process and checks a known set of items without invoking MSBuild at all. It compares timestamps of well-known item types (Compile, Content, EmbeddedResource, etc.) against the project's primary output.
- It can be wrong if your project uses custom build actions, custom targets that generate files, or non-standard item types that FUTDC doesn't know about.
- Disable FUTDC to force Visual Studio to use MSBuild's full incremental check:
<PropertyGroup> <DisableFastUpToDateCheck>true</DisableFastUpToDateCheck> </PropertyGroup> - Diagnose FUTDC decisions by viewing the Output window in VS: go to Tools → Options → Projects and Solutions → SDK-Style Projects and set Up-to-date Checks logging level to Verbose or above. FUTDC will log exactly which file it considers out of date.
- Common VS FUTDC issues:
- Custom build actions not registered with the FUTDC system
CopyToOutputDirectoryitems that are newer than the last build- Items added dynamically by targets that FUTDC doesn't evaluate
ContentorNoneitems withCopyToOutputDirectory="PreserveNewest"that have been modified
Making Custom Targets Incremental
The following is a complete example of a well-structured incremental custom target:
<Target Name="GenerateConfig"
Inputs="$(MSBuildProjectFile);@(ConfigInput)"
Outputs="$(IntermediateOutputPath)config.generated.cs"
BeforeTargets="CoreCompile">
<!-- Generate file only if inputs changed -->
<WriteLinesToFile File="$(IntermediateOutputPath)config.generated.cs" Lines="..." />
<ItemGroup>
<FileWrites Include="$(IntermediateOutputPath)config.generated.cs" />
<Compile Include="$(IntermediateOutputPath)config.generated.cs" />
</ItemGroup>
</Target>
Key points in this example:
Inputsincludes$(MSBuildProjectFile): This ensures the target reruns if the project file itself changes (e.g., a property that affects generation is modified).Inputsincludes@(ConfigInput): The actual source files that drive generation.Outputsuses$(IntermediateOutputPath): Generated files go in theobj/directory, which is managed by MSBuild and cleaned automatically.BeforeTargets="CoreCompile": The generated file is available before the compiler runs.FileWritesregistration: Ensuresdotnet cleanremoves the generated file.Compileinclusion: Adds the generated file to the compilation without requiring it to exist at evaluation time.
Common mistakes to avoid
<!-- BAD: No Inputs/Outputs — runs every build -->
<Target Name="BadTarget" BeforeTargets="CoreCompile">
<Exec Command="generate-code.exe" />
</Target>
<!-- BAD: Volatile output path — never finds previous output -->
<Target Name="BadTarget2"
Inputs="@(Compile)"
Outputs="$(OutputPath)gen_$([System.DateTime]::Now.Ticks).cs">
<Exec Command="generate-code.exe" />
</Target>
<!-- GOOD: Stable paths, registered outputs -->
<Target Name="GoodTarget"
Inputs="@(Compile)"
Outputs="$(IntermediateOutputPath)generated.cs"
BeforeTargets="CoreCompile">
<Exec Command="generate-code.exe -o $(IntermediateOutputPath)generated.cs" />
<Ite
Truncated for display — read the full file on GitHub.
Related Skills
ai-job-search
44.0kThe job search that runs on your machine. AI job application framework built on Claude Code: evaluate postings, tailor CVs, write cover letters, prep interviews. Fork it and own it.
claude-howto
41.7kA visual, example-driven guide to Claude Code — from basic concepts to advanced agents, with copy-paste templates that bring immediate value.
algorithmic-art
177.9kCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems.
pptx
177.9kUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an em…
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
