본문으로 건너뛰기
Skillpedia
배포 및 클라우드 (DevOps)5.8k · #14602

incremental-build

하는 일

이 스킬은 아무것도 바뀌지 않은 두 번째 실행에서 MSBuild가 대상을 다시 빌드하는 이유를 찾아 설정을 고칩니다. 변경 없는 빌드가 전체 빌드만큼 느린 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓아무것도 바뀌지 않았는데 빌드가 모든 것을 다시 실행할 때.
  • ✓사용자 정의 대상이 건너뛰어지지 않고 매번 실행될 때.
  • ✓첫 실행은 빠른데 반복 실행이 느릴 때.

스킬 링크

https://github.com/dotnet/skills/blob/main/plugins/dotnet-msbuild/skills/incremental-build/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/dotnet/skills/blob/main/plugins/dotnet-msbuild/skills/incremental-build/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“아무것도 바꾸지 않았는데 .NET 빌드가 프로젝트 전체를 다시 빌드합니다. 이유를 찾아서 고쳐 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트가 느린 대상의 입력과 출력 타임스탬프를 비교하고, 빠진 입력과 출력, 추적된 출력 밖에서 쓰인 파일을 찾은 뒤 수정을 제안하고, 같은 빌드를 두 번 실행해 확인합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 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 Inputs and Outputs attributes: MSBuild compares the timestamps of all files listed in Inputs against all files listed in Outputs. 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)

  1. Missing Inputs/Outputs on custom targets — Without both attributes, the target always runs. This is the single most common cause of unnecessary rebuilds.

  2. 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.

  3. 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.

  4. Missing FileWrites registration — Files created during the build but not registered in the FileWrites item group won't be cleaned by dotnet clean. Over time, stale files can confuse incremental checks.

  5. Glob changes — When you add or remove source files, the item set (e.g., @(Compile)) changes. Since these items feed into Inputs, the set of inputs changes and triggers a rebuild. This is expected behavior but can be surprising.

  6. Property changes — Properties that feed into Inputs or Outputs paths (e.g., $(Configuration), $(TargetFramework)) will cause rebuilds when changed. Switching between Debug and Release is a full rebuild by design.

  7. NuGet package updates — Changing a package version updates project.assets.json and potentially many resolved assembly paths. This changes the inputs to ResolveAssemblyReferences and CoreCompile, triggering a rebuild.

  8. 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:

  1. Actual timestamp comparison — name the newest resolved input and oldest resolved output, with their last-write times, and state which input is newer.
  2. **Output existence
자주 묻는 질문

변경 없는 빌드란 무엇인가요?

편집 없이 두 번째로 하는 빌드이며, 대상이 건너뛰어져서 빨리 끝나야 합니다.

요청하지 않아도 파일을 바꾸나요?

먼저 진단하며, 수정을 요청했을 때만 고칩니다.

변동 값이 왜 재빌드를 일으키나요?

출력 경로의 타임스탬프나 무작위 GUID처럼 매번 바뀌는 값은 MSBuild가 출력을 새것으로 취급하게 만듭니다.

상세 정보

작성자의 원본 설명

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

인기도

GitHub 스타
5.8k
순위
#14602
라이선스
MIT
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬