incremental-build
Was er macht
Dieser Skill findet heraus, warum MSBuild beim zweiten Lauf Ziele neu baut, obwohl sich nichts geändert hat, und behebt die Einrichtung. Er ist für Entwickler, deren Builds ohne Änderung genauso langsam sind wie vollständige Builds.
Wann du ihn nutzt
- ✓Wenn ein Build alles neu ausführt, obwohl sich nichts geändert hat.
- ✓Wenn ein eigenes Ziel bei jedem Lauf läuft, statt übersprungen zu werden.
- ✓Wenn ein Build bei Wiederholungen langsam ist, beim ersten Lauf aber nicht.
Link zum Skill
https://github.com/dotnet/skills/blob/main/plugins/dotnet-msbuild/skills/incremental-build/SKILL.mdKopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.
So nutzt du ihn
Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.
Fertige Nachricht zum Einfügen
Für Claude Code, Codex oder Cursor: Führe den Befehl in deinem Projektordner aus, dann wird der Skill installiert.
Lade die SKILL.md herunter und lege sie in den Skills-Ordner deines Agenten.
Beispielanfrage an deine KI
“Ich habe nichts geändert, aber mein .NET-Build baut trotzdem das ganze Projekt neu. Finde heraus, warum, und behebe es.”
5 neue Skills pro Woche. 1 Minute Lesezeit.
So funktioniert es
Der Agent vergleicht die Zeitstempel von Eingaben und Ausgaben für die langsamen Ziele, findet fehlende Ein- und Ausgaben oder Dateien, die außerhalb der verfolgten Ausgaben geschrieben werden, und schlägt eine Korrektur vor. Er prüft das mit zwei identischen Builds.
Technischer Inhalt (originale SKILL.md)
Originaltext des Autors, auf Englisch, direkt von GitHub.
Required diagnosis output
For every diagnose or explain request, the final answer must explicitly cover
all of these points, even when the immediate cause is simply missing
Inputs/Outputs:
- the target and exact root-cause evidence;
- the actual input/output timestamp comparison;
- missing, deleted, cleaned, or rewritten outputs;
- complete inputs, including dynamic or volatile inputs;
- evaluated input/output paths and one-to-one mapping when item lists are batched;
- two identical no-change builds and the expected second-build skip/out-of-date evidence.
Do not edit unless the user asks for a fix. If a check cannot be run, label it
as an unverified check rather than omitting it or claiming success. When
Inputs or Outputs are absent, report timestamp comparison or one-to-one
mapping as not applicable — the incremental mechanism is not engaged, not
as an unverified comparison.
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. - 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.
Before recommending a fix, report this compact checklist for each target that reran:
- Actual timestamp comparison — name the newest resolved input and oldest resolved output, with their last-write times, and state which input is newer.
- **Output existence
Häufige Fragen
Was bedeutet ein Build ohne Änderung?
Es ist ein zweiter Build ohne Bearbeitung, der schnell fertig sein sollte, wobei seine Ziele übersprungen werden.
Ändert es Dateien ohne Nachfrage?
Es stellt zuerst die Diagnose und nimmt nur dann eine Korrektur vor, wenn du sie verlangst.
Warum lösen flüchtige Werte Neubauten aus?
Werte wie Zeitstempel oder zufällige GUIDs in Ausgabepfaden ändern sich bei jedem Build, daher hält MSBuild die Ausgaben für neu.
Details
Originalbeschreibung des Autors
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 buil
repo: dotnet/skills
Beliebtheit
- GitHub-Sterne
- 5.8k
- Platz im Ranking
- #14602
- Lizenz
- MIT
- Aktualisiert
- 2.11.2026
Kommentare
- …
Weitere Skills aus diesem Repository
create-custom-agent
5.8kHilft deinem Agenten, Agenten-Dateien für VS Code zu erstellen, mit eigenen Werkzeugen, Anweisungen und Übergaben an andere Agenten.
create-skill
5.8kHilft deinem Agenten, einen neuen Agenten-Skill mit gültigem Namen, klarer Auslöserbeschreibung und einer SKILL.md-Datei nach dem Standard zu erstellen.
csharp-scripts
5.8kHilft deinem Agenten, ein kleines C#-Programm als einzelne Datei mit dem .NET-Kommandozeilen-Tool auszuführen, ohne ein vollständiges Projekt anzulegen.
dotnet-pinvoke
5.8kHilft deinem Agenten, native C- oder C++-Bibliotheken korrekt aus .NET aufzurufen, mit Signaturen, Zeichenkettenbehandlung, Speicher und sicheren Handles.
Ähnliche Skills
openclaw-update
394kHilft deinem Agenten, ein bestehendes OpenClaw-Gateway zu aktualisieren, mit der Methode, die zu deiner Installation passt, während deine Sitzung weiterläuft.
diagnose-gateway
394kHilft deinem Agenten herauszufinden, warum dein OpenClaw-Gateway fehlschlägt, indem er Einstellungen, Kanäle und Ports prüft, ohne etwas zu ändern.
crabbox-apps
394kHilft deinem Agenten, eine App auf einer temporären Cloud-Maschine zu öffnen und auszuführen und ihre Ansicht in deinem Chat-Seitenpanel zu zeigen.