[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M699EK40NSFRBNH6ZNV7DCX9":3,"skill-same:01M699EK40NSFRBNH6ZNV7DCX9":70},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":18,"categories":19,"keywords":30,"publishedAt":42,"linkOnly":43,"markdownContent":44,"markdownBody":45,"frontMatter":46,"refName":47,"commitSha":48,"skillDirectory":49,"forksCount":50,"repositoryHtmlUrl":51,"repositoryHomepageUrl":17,"ownerHtmlUrl":52,"ownerBlogUrl":53,"ownerDescription":54,"updatedAt":55,"install":56,"resources":69},"01M699EK40NSFRBNH6ZNV7DCX9","incremental-build","MSBuild 增量构建诊断","Diagnose unnecessary MSBuild target execution via inputs\u002Foutputs and no-change builds; not first-build cost, parallelism or evaluation slowness.","通过输入\u002F输出和无变更构建（no-change builds）诊断不必要的 MSBuild 目标执行；不用于首次构建成本、并行性或求值（evaluation）缓慢的问题。","microsoft\u002Ftestfx","microsoft","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F6154722?v=4","01M698VYDXZ6JW5WH3CRV650R8","Microsoft","01M699C71CJ91B5WZ3AXG3GG2M",1059,"MIT",null,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftestfx\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fincremental-build\u002FSKILL.md",[20,25],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BQ6TQZN6R52WBJ9H8NRMQM","软件开发工程师","PROFESSION","适用职业",{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BSTR9G4A4GZ0VB2DFN9490","开发环境与工具链管理","SCENARIO","使用场景",[31,32,33,34,35,36,37,38,39,40,41],"incremental build","build","change","msbuild","diagnose","Evaluation","execution","first","cost","via","outputs","2026-11-10 10:12:30",false,"---\nname: incremental-build\ndescription: \"Diagnose unnecessary MSBuild target execution via inputs\u002Foutputs and no-change builds; not first-build cost, parallelism or evaluation slowness.\"\nlicense: MIT\n---\n\n## Scope and routing\n\nGuide 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\u002FOutputs on custom targets, volatile properties in output paths (timestamps\u002FGUIDs), 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.\n\n## Required diagnosis output\n\nFor every diagnose or explain request, the final answer must explicitly cover\nall of these points, even when the immediate cause is simply missing\n`Inputs`\u002F`Outputs`:\n\n- the target and exact root-cause evidence;\n- the actual input\u002Foutput timestamp comparison;\n- missing, deleted, cleaned, or rewritten outputs;\n- complete inputs, including dynamic or volatile inputs;\n- evaluated input\u002Foutput paths and one-to-one mapping when item lists are batched;\n- two identical no-change builds and the expected second-build skip\u002Fout-of-date evidence.\n\nDo not edit unless the user asks for a fix. If a check cannot be run, label it\nas an unverified check rather than omitting it or claiming success. When\n`Inputs` or `Outputs` are absent, report timestamp comparison or one-to-one\nmapping as **not applicable — the incremental mechanism is not engaged**, not\nas an unverified comparison.\n\n## How MSBuild Incremental Build Works\n\nMSBuild's incremental build mechanism allows targets to be skipped when their outputs are already up to date, dramatically reducing build times on subsequent runs.\n\n- **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.\n- **Without `Inputs`\u002F`Outputs`**: The target runs every time the build is invoked. This is the default behavior and the most common cause of slow incremental builds.\n- **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.\n\n```xml\n\u003C!-- This target is incremental: skipped if Output is newer than all Inputs -->\n\u003CTarget Name=\"Transform\"\n        Inputs=\"@(TransformFiles)\"\n        Outputs=\"@(TransformFiles->'$(OutputPath)%(Filename).out')\">\n  \u003C!-- work here -->\n\u003C\u002FTarget>\n\n\u003C!-- This target always runs because it has no Inputs\u002FOutputs -->\n\u003CTarget Name=\"PrintMessage\">\n  \u003CMessage Text=\"This runs every build\" \u002F>\n\u003C\u002FTarget>\n```\n\n## Why Incremental Builds Break (Top Causes)\n\n1. **Missing Inputs\u002FOutputs on custom targets** — Without both attributes, the target always runs. This is the single most common cause of unnecessary rebuilds.\n\n2. **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.\n\n3. **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.\n\n4. **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.\n\n5. **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.\n\n6. **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.\n\n7. **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.\n\n8. **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.\n\n## Diagnosing \"Why Did This Rebuild?\"\n\nUse binary logs (binlogs) to understand exactly why targets ran instead of being skipped.\n\nBefore recommending a fix, report this compact checklist for each target that reran:\n\n1. **Actual timestamp comparison** — name the newest resolved input and oldest resolved output, with their last-write times, and state which input is newer.\n2. **Output existence** — confirm every declared output exists before the second build and is not deleted, cleaned, or rewritten by another target.\n3. **Complete inputs** — verify `Inputs` includes every file that should invalidate the output, including volatile or generated dependencies. If a producer touches an input on every build, check whether its content changes. Fix unnecessary rewrites in the producer (for example, write only when content changes); if relevant content really changes, the dependent target must rerun. Exclude a file only with evidence that it cannot affect the output, never just because it changes often.\n4. **Stable resolved paths** — expand properties and relative paths for both builds; outputs must resolve to the same location and must not contain timestamps, build numbers, or GUIDs.\n5. **One-to-one mapping when batched** — for item transforms, map each input identity to its expected output and report missing, duplicate, or unmatched pairs.\n6. **No-change verification** — run the same build twice without edits and cite the second build's skip or out-of-date reason.\n\nFor a diagnosis or explanation request, do not edit the project unless the user asks for a fix. If build execution is unavailable, distinguish inspected facts from expected behavior and do not claim the fix was applied or verified.\n\n`Overwrite=\"true\"` on `WriteLinesToFile` is not itself a reason that an\nincremental target reruns. The task rewrites the file only after MSBuild has\nalready scheduled the target; correct `Inputs`\u002F`Outputs` can skip the target\nbefore the task executes.\n\n### Step-by-step using binlog\n\n1. **Build twice without edits** and capture both structured and text evidence\n   from the second build:\n   ```shell\n   dotnet build \u002Fbl:first.binlog\n   dotnet build \u002Fbl:second.binlog -fl \"-flp:v=diag;logfile=second-full.log;performancesummary\"\n   ```\n   The first build establishes the baseline. The second build is the one you want to be incremental. Analyze `second.binlog`.\n\n### Primary: binlog MCP (preferred)\n\nUse the **binlog MCP server** (`Microsoft.AITools.BinlogMcp`, exposed under the `binlog` MCP namespace) to analyze the second binlog:\n\n1. Use `load_binlog` to load `second.binlog`.\n2. Use `search_binlog` for \"Building target completely\", \"Building target incrementally\", \"Skipping target\", and \"is newer than output\".\n3. Use `get_target_info_by_name` for the target that reran.\n4. Use `get_project_target_list` to confirm the target and its project context.\n5. Use `get_expensive_targets` only to rank the non-skipped targets after the skip reason is understood.\n\n### Fallback: diagnostic text log (when MCP is unavailable)\n\n2. **Read the diagnostic log captured during the second build**. Do not run\n   another build or depend on replay support for the default fallback:\n   ```bash\n   grep 'Building target\\|Target.*was not skipped' second-full.log\n   ```\n   In a perfectly incremental build, most targets should be skipped.\n\n3. **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.\n\n4. **Look for key messages** in the binlog:\n   - `\"Building target 'X' completely\"` — means MSBuild found no outputs or all outputs are missing; this is a full target execution.\n   - `\"Building target 'X' incrementally\"` — means some (but not all) outputs are out of date.\n   - `\"Skipping target 'X' because all output files are up-to-date\"` — target was correctly skipped.\n\n5. **Search for \"is newer than output\"** messages to find the specific input file that triggered the rebuild:\n   ```bash\n   grep \"is newer than output\" second-full.log\n   ```\n   This reveals exactly which input file's timestamp caused MSBuild to consider the target out of date.\n\n### Additional diagnostic techniques\n\n- Compare `first.binlog` and `second.binlog` side by side in the MSBuild Structured Log Viewer to see what changed.\n- Use `grep 'Target Performance Summary' -A 30 second-full.log` to see which targets consumed the most time in the second build — these are your optimization targets.\n- Check for targets with zero-duration that still ran — they may have unnecessary dependencies causing them to execute.\n\n## FileWrites and Clean Build\n\nThe `FileWrites` item group is MSBuild's mechanism for tracking files generated during the build. It powers `dotnet clean` and helps maintain correct incremental behavior.\n\n- **`FileWrites` item**: Register any file your custom targets create so that `dotnet clean` knows to remove them. Without this, generated files accumulate across builds and may confuse incremental checks.\n- **`FileWritesShareable` item**: 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.\n- **If not registered**: Files accumulate in the output and intermediate directories. `dotnet clean` won't remove them, and they may cause stale data issues or confuse up-to-date checks.\n\n### Pattern for registering generated files\n\nAdd generated files to `FileWrites` inside the target that creates them:\n\n```xml\n\u003CTarget Name=\"MyGenerator\" Inputs=\"...\" Outputs=\"$(IntermediateOutputPath)generated.cs\">\n  \u003C!-- Generate the file -->\n  \u003CWriteLinesToFile File=\"$(IntermediateOutputPath)generated.cs\" Lines=\"@(GeneratedLines)\" \u002F>\n\n  \u003C!-- Register for clean -->\n  \u003CItemGroup>\n    \u003CFileWrites Include=\"$(IntermediateOutputPath)generated.cs\" \u002F>\n  \u003C\u002FItemGroup>\n\u003C\u002FTarget>\n```\n\n## Visual Studio Fast Up-to-Date Check\n\nVisual Studio has its own up-to-date check (Fast Up-to-Date Check, or FUTDC) that is separate from MSBuild's `Inputs`\u002F`Outputs` mechanism. Understanding the difference is critical for diagnosing \"it rebuilds in VS but not on the command line\" issues.\n\n- **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.\n- **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.\n- **Disable FUTDC** to force Visual Studio to use MSBuild's full incremental check:\n  ```xml\n  \u003CPropertyGroup>\n    \u003CDisableFastUpToDateCheck>true\u003C\u002FDisableFastUpToDateCheck>\n  \u003C\u002FPropertyGroup>\n  ```\n- **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.\n- **Common VS FUTDC issues**:\n  - Custom build actions not registered with the FUTDC system\n  - `CopyToOutputDirectory` items that are newer than the last build\n  - Items added dynamically by targets that FUTDC doesn't evaluate\n  - `Content` or `None` items with `CopyToOutputDirectory=\"PreserveNewest\"` that have been modified\n\n## Making Custom Targets Incremental\n\nThe following is a complete example of a well-structured incremental custom target:\n\n```xml\n\u003CTarget Name=\"GenerateConfig\"\n        Inputs=\"$(MSBuildProjectFile);@(ConfigInput)\"\n        Outputs=\"$(IntermediateOutputPath)config.generated.cs\"\n        BeforeTargets=\"CoreCompile\">\n  \u003C!-- Generate file only if inputs changed -->\n  \u003CWriteLinesToFile File=\"$(IntermediateOutputPath)config.generated.cs\" Lines=\"...\" \u002F>\n  \u003CItemGroup>\n    \u003CFileWrites Include=\"$(IntermediateOutputPath)config.generated.cs\" \u002F>\n    \u003CCompile Include=\"$(IntermediateOutputPath)config.generated.cs\" \u002F>\n  \u003C\u002FItemGroup>\n\u003C\u002FTarget>\n```\n\n**Key points in this example:**\n\n- **`Inputs` includes `$(MSBuildProjectFile)`**: This ensures the target reruns if the project file itself changes (e.g., a property that affects generation is modified).\n- **`Inputs` includes `@(ConfigInput)`**: The actual source files that drive generation.\n- **`Outputs` uses `$(IntermediateOutputPath)`**: Generated files go in the `obj\u002F` directory, which is managed by MSBuild and cleaned automatically.\n- **`BeforeTargets=\"CoreCompile\"`**: The generated file is available before the compiler runs.\n- **`FileWrites` registration**: Ensures `dotnet clean` removes the generated file.\n- **`Compile` inclusion**: Adds the generated file to the compilation without requiring it to exist at evaluation time.\n\n### Common mistakes to avoid\n\n```xml\n\u003C!-- BAD: No Inputs\u002FOutputs — runs every build -->\n\u003CTarget Name=\"BadTarget\" BeforeTargets=\"CoreCompile\">\n  \u003CExec Command=\"generate-code.exe\" \u002F>\n\u003C\u002FTarget>\n\n\u003C!-- BAD: Volatile output path — never finds previous output -->\n\u003CTarget Name=\"BadTarget2\"\n        Inputs=\"@(Compile)\"\n        Outputs=\"$(OutputPath)gen_$([System.DateTime]::Now.Ticks).cs\">\n  \u003CExec Command=\"generate-code.exe\" \u002F>\n\u003C\u002FTarget>\n\n\u003C!-- GOOD: Stable paths, registered outputs -->\n\u003CTarget Name=\"GoodTarget\"\n        Inputs=\"@(Compile)\"\n        Outputs=\"$(IntermediateOutputPath)generated.cs\"\n        BeforeTargets=\"CoreCompile\">\n  \u003CExec Command=\"generate-code.exe -o $(IntermediateOutputPath)generated.cs\" \u002F>\n  \u003CItemGroup>\n    \u003CFileWrites Include=\"$(IntermediateOutputPath)generated.cs\" \u002F>\n    \u003CCompile Include=\"$(IntermediateOutputPath)generated.cs\" \u002F>\n  \u003C\u002FItemGroup>\n\u003C\u002FTarget>\n```\n\n## Performance Summary and Preprocess\n\nMSBuild provides built-in tools to understand what's running and why.\n\n- **`\u002Fclp:PerformanceSummary`** — Appends a summary at the end of the build showing time spent in each target and task. Use this to quickly identify the most expensive operations:\n  ```shell\n  dotnet build \u002Fclp:PerformanceSummary\n  ```\n  This shows a table of targets sorted by cumulative time, making it easy to spot targets that shouldn't be running in an incremental build.\n\n- **`\u002Fpp:preprocess.xml`** — Generates a single XML file with all imports inlined, showing the fully evaluated project. This is invaluable for understanding what targets, properties, and items are defined and where they come from:\n  ```shell\n  dotnet msbuild \u002Fpp:preprocess.xml\n  ```\n  Search the preprocessed output to find where `Inputs` and `Outputs` are defined for any target, or to understand the full chain of imports.\n\n- Use both together to understand what's running (`PerformanceSummary`) and what's imported (`\u002Fpp`), then cross-reference with binlog analysis for a complete picture.\n\n## Common Fixes\n\n- **Always add `Inputs` and `Outputs` to custom targets** — This is the single most impactful change for incremental build performance. Without both attributes, the target runs every time.\n- **Use `$(IntermediateOutputPath)` for generated files** — Files in `obj\u002F` are tracked by MSBuild's clean infrastructure and won't leak between configurations.\n- **Register generated files in `FileWrites`** — Ensures `dotnet clean` removes them and prevents stale file accumulation.\n- **Avoid unnecessary volatility in producers** — Don't embed timestamps, random values, or build counters in file paths or generated content unless required. Preserve generated-file timestamps when content is unchanged (for example, `Overwrite=\"true\" WriteOnlyWhenDifferent=\"true\"` with `WriteLinesToFile`). Keep real dependencies in `Inputs`; if required volatile content changes, accept the dependent rebuild. Exclude a file only after proving it cannot affect the output.\n- **Use `Returns` instead of `Outputs` when you need to pass items without creating incremental build dependency** — `Outputs` serves double duty: it defines the incremental check AND the items returned from the target. If you only need to pass items to calling targets without affecting incrementality, use `Returns` instead:\n  ```xml\n  \u003C!-- Outputs: affects incremental check AND return value -->\n  \u003CTarget Name=\"GetFiles\" Outputs=\"@(DiscoveredFiles)\">...\u003C\u002FTarget>\n\n  \u003C!-- Returns: only affects return value, no incremental check -->\n  \u003CTarget Name=\"GetFiles\" Returns=\"@(DiscoveredFiles)\">...\u003C\u002FTarget>\n  ```\n","## Scope and routing\n\nGuide 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\u002FOutputs on custom targets, volatile properties in output paths (timestamps\u002FGUIDs), 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.\n\n## Required diagnosis output\n\nFor every diagnose or explain request, the final answer must explicitly cover\nall of these points, even when the immediate cause is simply missing\n`Inputs`\u002F`Outputs`:\n\n- the target and exact root-cause evidence;\n- the actual input\u002Foutput timestamp comparison;\n- missing, deleted, cleaned, or rewritten outputs;\n- complete inputs, including dynamic or volatile inputs;\n- evaluated input\u002Foutput paths and one-to-one mapping when item lists are batched;\n- two identical no-change builds and the expected second-build skip\u002Fout-of-date evidence.\n\nDo not edit unless the user asks for a fix. If a check cannot be run, label it\nas an unverified check rather than omitting it or claiming success. When\n`Inputs` or `Outputs` are absent, report timestamp comparison or one-to-one\nmapping as **not applicable — the incremental mechanism is not engaged**, not\nas an unverified comparison.\n\n## How MSBuild Incremental Build Works\n\nMSBuild's incremental build mechanism allows targets to be skipped when their outputs are already up to date, dramatically reducing build times on subsequent runs.\n\n- **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.\n- **Without `Inputs`\u002F`Outputs`**: The target runs every time the build is invoked. This is the default behavior and the most common cause of slow incremental builds.\n- **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.\n\n```xml\n\u003C!-- This target is incremental: skipped if Output is newer than all Inputs -->\n\u003CTarget Name=\"Transform\"\n        Inputs=\"@(TransformFiles)\"\n        Outputs=\"@(TransformFiles->'$(OutputPath)%(Filename).out')\">\n  \u003C!-- work here -->\n\u003C\u002FTarget>\n\n\u003C!-- This target always runs because it has no Inputs\u002FOutputs -->\n\u003CTarget Name=\"PrintMessage\">\n  \u003CMessage Text=\"This runs every build\" \u002F>\n\u003C\u002FTarget>\n```\n\n## Why Incremental Builds Break (Top Causes)\n\n1. **Missing Inputs\u002FOutputs on custom targets** — Without both attributes, the target always runs. This is the single most common cause of unnecessary rebuilds.\n\n2. **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.\n\n3. **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.\n\n4. **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.\n\n5. **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.\n\n6. **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.\n\n7. **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.\n\n8. **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.\n\n## Diagnosing \"Why Did This Rebuild?\"\n\nUse binary logs (binlogs) to understand exactly why targets ran instead of being skipped.\n\nBefore recommending a fix, report this compact checklist for each target that reran:\n\n1. **Actual timestamp comparison** — name the newest resolved input and oldest resolved output, with their last-write times, and state which input is newer.\n2. **Output existence** — confirm every declared output exists before the second build and is not deleted, cleaned, or rewritten by another target.\n3. **Complete inputs** — verify `Inputs` includes every file that should invalidate the output, including volatile or generated dependencies. If a producer touches an input on every build, check whether its content changes. Fix unnecessary rewrites in the producer (for example, write only when content changes); if relevant content really changes, the dependent target must rerun. Exclude a file only with evidence that it cannot affect the output, never just because it changes often.\n4. **Stable resolved paths** — expand properties and relative paths for both builds; outputs must resolve to the same location and must not contain timestamps, build numbers, or GUIDs.\n5. **One-to-one mapping when batched** — for item transforms, map each input identity to its expected output and report missing, duplicate, or unmatched pairs.\n6. **No-change verification** — run the same build twice without edits and cite the second build's skip or out-of-date reason.\n\nFor a diagnosis or explanation request, do not edit the project unless the user asks for a fix. If build execution is unavailable, distinguish inspected facts from expected behavior and do not claim the fix was applied or verified.\n\n`Overwrite=\"true\"` on `WriteLinesToFile` is not itself a reason that an\nincremental target reruns. The task rewrites the file only after MSBuild has\nalready scheduled the target; correct `Inputs`\u002F`Outputs` can skip the target\nbefore the task executes.\n\n### Step-by-step using binlog\n\n1. **Build twice without edits** and capture both structured and text evidence\n   from the second build:\n   ```shell\n   dotnet build \u002Fbl:first.binlog\n   dotnet build \u002Fbl:second.binlog -fl \"-flp:v=diag;logfile=second-full.log;performancesummary\"\n   ```\n   The first build establishes the baseline. The second build is the one you want to be incremental. Analyze `second.binlog`.\n\n### Primary: binlog MCP (preferred)\n\nUse the **binlog MCP server** (`Microsoft.AITools.BinlogMcp`, exposed under the `binlog` MCP namespace) to analyze the second binlog:\n\n1. Use `load_binlog` to load `second.binlog`.\n2. Use `search_binlog` for \"Building target completely\", \"Building target incrementally\", \"Skipping target\", and \"is newer than output\".\n3. Use `get_target_info_by_name` for the target that reran.\n4. Use `get_project_target_list` to confirm the target and its project context.\n5. Use `get_expensive_targets` only to rank the non-skipped targets after the skip reason is understood.\n\n### Fallback: diagnostic text log (when MCP is unavailable)\n\n2. **Read the diagnostic log captured during the second build**. Do not run\n   another build or depend on replay support for the default fallback:\n   ```bash\n   grep 'Building target\\|Target.*was not skipped' second-full.log\n   ```\n   In a perfectly incremental build, most targets should be skipped.\n\n3. **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.\n\n4. **Look for key messages** in the binlog:\n   - `\"Building target 'X' completely\"` — means MSBuild found no outputs or all outputs are missing; this is a full target execution.\n   - `\"Building target 'X' incrementally\"` — means some (but not all) outputs are out of date.\n   - `\"Skipping target 'X' because all output files are up-to-date\"` — target was correctly skipped.\n\n5. **Search for \"is newer than output\"** messages to find the specific input file that triggered the rebuild:\n   ```bash\n   grep \"is newer than output\" second-full.log\n   ```\n   This reveals exactly which input file's timestamp caused MSBuild to consider the target out of date.\n\n### Additional diagnostic techniques\n\n- Compare `first.binlog` and `second.binlog` side by side in the MSBuild Structured Log Viewer to see what changed.\n- Use `grep 'Target Performance Summary' -A 30 second-full.log` to see which targets consumed the most time in the second build — these are your optimization targets.\n- Check for targets with zero-duration that still ran — they may have unnecessary dependencies causing them to execute.\n\n## FileWrites and Clean Build\n\nThe `FileWrites` item group is MSBuild's mechanism for tracking files generated during the build. It powers `dotnet clean` and helps maintain correct incremental behavior.\n\n- **`FileWrites` item**: Register any file your custom targets create so that `dotnet clean` knows to remove them. Without this, generated files accumulate across builds and may confuse incremental checks.\n- **`FileWritesShareable` item**: 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.\n- **If not registered**: Files accumulate in the output and intermediate directories. `dotnet clean` won't remove them, and they may cause stale data issues or confuse up-to-date checks.\n\n### Pattern for registering generated files\n\nAdd generated files to `FileWrites` inside the target that creates them:\n\n```xml\n\u003CTarget Name=\"MyGenerator\" Inputs=\"...\" Outputs=\"$(IntermediateOutputPath)generated.cs\">\n  \u003C!-- Generate the file -->\n  \u003CWriteLinesToFile File=\"$(IntermediateOutputPath)generated.cs\" Lines=\"@(GeneratedLines)\" \u002F>\n\n  \u003C!-- Register for clean -->\n  \u003CItemGroup>\n    \u003CFileWrites Include=\"$(IntermediateOutputPath)generated.cs\" \u002F>\n  \u003C\u002FItemGroup>\n\u003C\u002FTarget>\n```\n\n## Visual Studio Fast Up-to-Date Check\n\nVisual Studio has its own up-to-date check (Fast Up-to-Date Check, or FUTDC) that is separate from MSBuild's `Inputs`\u002F`Outputs` mechanism. Understanding the difference is critical for diagnosing \"it rebuilds in VS but not on the command line\" issues.\n\n- **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.\n- **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.\n- **Disable FUTDC** to force Visual Studio to use MSBuild's full incremental check:\n  ```xml\n  \u003CPropertyGroup>\n    \u003CDisableFastUpToDateCheck>true\u003C\u002FDisableFastUpToDateCheck>\n  \u003C\u002FPropertyGroup>\n  ```\n- **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.\n- **Common VS FUTDC issues**:\n  - Custom build actions not registered with the FUTDC system\n  - `CopyToOutputDirectory` items that are newer than the last build\n  - Items added dynamically by targets that FUTDC doesn't evaluate\n  - `Content` or `None` items with `CopyToOutputDirectory=\"PreserveNewest\"` that have been modified\n\n## Making Custom Targets Incremental\n\nThe following is a complete example of a well-structured incremental custom target:\n\n```xml\n\u003CTarget Name=\"GenerateConfig\"\n        Inputs=\"$(MSBuildProjectFile);@(ConfigInput)\"\n        Outputs=\"$(IntermediateOutputPath)config.generated.cs\"\n        BeforeTargets=\"CoreCompile\">\n  \u003C!-- Generate file only if inputs changed -->\n  \u003CWriteLinesToFile File=\"$(IntermediateOutputPath)config.generated.cs\" Lines=\"...\" \u002F>\n  \u003CItemGroup>\n    \u003CFileWrites Include=\"$(IntermediateOutputPath)config.generated.cs\" \u002F>\n    \u003CCompile Include=\"$(IntermediateOutputPath)config.generated.cs\" \u002F>\n  \u003C\u002FItemGroup>\n\u003C\u002FTarget>\n```\n\n**Key points in this example:**\n\n- **`Inputs` includes `$(MSBuildProjectFile)`**: This ensures the target reruns if the project file itself changes (e.g., a property that affects generation is modified).\n- **`Inputs` includes `@(ConfigInput)`**: The actual source files that drive generation.\n- **`Outputs` uses `$(IntermediateOutputPath)`**: Generated files go in the `obj\u002F` directory, which is managed by MSBuild and cleaned automatically.\n- **`BeforeTargets=\"CoreCompile\"`**: The generated file is available before the compiler runs.\n- **`FileWrites` registration**: Ensures `dotnet clean` removes the generated file.\n- **`Compile` inclusion**: Adds the generated file to the compilation without requiring it to exist at evaluation time.\n\n### Common mistakes to avoid\n\n```xml\n\u003C!-- BAD: No Inputs\u002FOutputs — runs every build -->\n\u003CTarget Name=\"BadTarget\" BeforeTargets=\"CoreCompile\">\n  \u003CExec Command=\"generate-code.exe\" \u002F>\n\u003C\u002FTarget>\n\n\u003C!-- BAD: Volatile output path — never finds previous output -->\n\u003CTarget Name=\"BadTarget2\"\n        Inputs=\"@(Compile)\"\n        Outputs=\"$(OutputPath)gen_$([System.DateTime]::Now.Ticks).cs\">\n  \u003CExec Command=\"generate-code.exe\" \u002F>\n\u003C\u002FTarget>\n\n\u003C!-- GOOD: Stable paths, registered outputs -->\n\u003CTarget Name=\"GoodTarget\"\n        Inputs=\"@(Compile)\"\n        Outputs=\"$(IntermediateOutputPath)generated.cs\"\n        BeforeTargets=\"CoreCompile\">\n  \u003CExec Command=\"generate-code.exe -o $(IntermediateOutputPath)generated.cs\" \u002F>\n  \u003CItemGroup>\n    \u003CFileWrites Include=\"$(IntermediateOutputPath)generated.cs\" \u002F>\n    \u003CCompile Include=\"$(IntermediateOutputPath)generated.cs\" \u002F>\n  \u003C\u002FItemGroup>\n\u003C\u002FTarget>\n```\n\n## Performance Summary and Preprocess\n\nMSBuild provides built-in tools to understand what's running and why.\n\n- **`\u002Fclp:PerformanceSummary`** — Appends a summary at the end of the build showing time spent in each target and task. Use this to quickly identify the most expensive operations:\n  ```shell\n  dotnet build \u002Fclp:PerformanceSummary\n  ```\n  This shows a table of targets sorted by cumulative time, making it easy to spot targets that shouldn't be running in an incremental build.\n\n- **`\u002Fpp:preprocess.xml`** — Generates a single XML file with all imports inlined, showing the fully evaluated project. This is invaluable for understanding what targets, properties, and items are defined and where they come from:\n  ```shell\n  dotnet msbuild \u002Fpp:preprocess.xml\n  ```\n  Search the preprocessed output to find where `Inputs` and `Outputs` are defined for any target, or to understand the full chain of imports.\n\n- Use both together to understand what's running (`PerformanceSummary`) and what's imported (`\u002Fpp`), then cross-reference with binlog analysis for a complete picture.\n\n## Common Fixes\n\n- **Always add `Inputs` and `Outputs` to custom targets** — This is the single most impactful change for incremental build performance. Without both attributes, the target runs every time.\n- **Use `$(IntermediateOutputPath)` for generated files** — Files in `obj\u002F` are tracked by MSBuild's clean infrastructure and won't leak between configurations.\n- **Register generated files in `FileWrites`** — Ensures `dotnet clean` removes them and prevents stale file accumulation.\n- **Avoid unnecessary volatility in producers** — Don't embed timestamps, random values, or build counters in file paths or generated content unless required. Preserve generated-file timestamps when content is unchanged (for example, `Overwrite=\"true\" WriteOnlyWhenDifferent=\"true\"` with `WriteLinesToFile`). Keep real dependencies in `Inputs`; if required volatile content changes, accept the dependent rebuild. Exclude a file only after proving it cannot affect the output.\n- **Use `Returns` instead of `Outputs` when you need to pass items without creating incremental build dependency** — `Outputs` serves double duty: it defines the incremental check AND the items returned from the target. If you only need to pass items to calling targets without affecting incrementality, use `Returns` instead:\n  ```xml\n  \u003C!-- Outputs: affects incremental check AND return value -->\n  \u003CTarget Name=\"GetFiles\" Outputs=\"@(DiscoveredFiles)\">...\u003C\u002FTarget>\n\n  \u003C!-- Returns: only affects return value, no incremental check -->\n  \u003CTarget Name=\"GetFiles\" Returns=\"@(DiscoveredFiles)\">...\u003C\u002FTarget>\n  ```\n",{"name":5,"license":16,"description":7},"main","f8f2bfd77819bb789d4736ce7db4a567a37fcf7e",".agents\u002Fskills\u002Fincremental-build",315,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftestfx","https:\u002F\u002Fgithub.com\u002Fmicrosoft","https:\u002F\u002Fopensource.microsoft.com","Open source projects and samples from Microsoft","2026-11-14 14:01:43",{"source":9,"skillName":5,"commands":57,"prompt":67,"zipAvailable":68},[58,61,64],{"tool":59,"command":60},"npx","npx skills add microsoft\u002Ftestfx --skill incremental-build",{"tool":62,"command":63},"bunx","bunx skills add microsoft\u002Ftestfx --skill incremental-build",{"tool":65,"command":66},"pnpm","pnpm dlx skills add microsoft\u002Ftestfx --skill incremental-build","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftestfx\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fincremental-build\u002FSKILL.md",true,[],[71,98,132,157,180,206],{"skillNo":72,"name":73,"nameZh":17,"description":74,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":42},"01M70GYY0AV0JGMTHE2CN6TNYK","dotnet-breaking-changes","Use before changing .NET\u002FC# code whose callers you do not control: a NuGet library, or a repo with PublicAPI.Shipped\u002FUnshipped.txt, ApiCompat, multiple TargetFrameworks, InternalsVisibleTo, or generated (.g.cs) partials. Green builds miss silent breaks from optional parameters, parameter names, sealing, const values, nullability, and #if. USE FOR: \"without breaking existing callers\"; adding a public method, overload, optional parameter, or interface member to a shipped library; renaming a public method or an internal helper a friend assembly uses; consolidating duplicated logic; changing a signature, nullability, default, or attribute; adding a target framework; RS0016\u002FRS0017 or ApiCompat errors; \"is this PR breaking?\". For a rename, extract, or merge, also invoke csharp-refactoring. DO NOT USE FOR: an executable whose callers all live in one project; renaming a local variable or private member, even in a shipped library; formatting; framework\u002FSDK\u002FNuGet upgrades (use dotnet-upgrade).","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftestfx\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fdotnet-breaking-changes\u002FSKILL.md",[],[78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97],"dotnet","dotnet breaking changes","changes","green","project","default","local","errors","interface","generated","upgrade","invoke","you","code","refactoring","merge","rename","library","live","assembly",{"skillNo":99,"name":100,"nameZh":101,"description":102,"descriptionZh":103,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":104,"categories":105,"keywords":112,"publishedAt":42},"01M699HHE9DTZWAMPB1ZR7ZKSW","testfx-test-value-evidence","TestFx 测试值证据应用","Apply the vendored test-value-evidence skill with TestFx toolchain, assertion, parallel-safety, packed-consumer, and review conventions. Use when implementing or reviewing behavior-changing TestFx PRs or commits, including source-only changes.","结合 TestFx 工具链、断言、并行安全、打包消费者（packed-consumer）和评审约定，应用项目内置的 test-value-evidence 技能。在实现或评审会改变行为的 TestFx PR 或提交时使用，包括仅修改源代码的变更。","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftestfx\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftestfx-test-value-evidence\u002FSKILL.md",[106,109],{"categoryNo":107,"categoryName":108,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BQGD5WG86P4AQ5GPSSKBFR","测试工程师",{"categoryNo":110,"categoryName":111,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BQJH394GT47X57A9Q8G7HX","测试与质量保障",[113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,80,129,130,131],"test","testfx test value evidence","test value evidence","evidence","value","review","parallel","toolchain","commits","implementing","prs","only","use","when","apply","with","behavior","Safety","conventions",{"skillNo":133,"name":134,"nameZh":135,"description":136,"descriptionZh":137,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":138,"categories":139,"keywords":142,"publishedAt":42},"01M699HEYWH1B9XGNBFY8J2FZS","testfx-parallel-safety-preflight","TestFx 并行安全预检","Check concurrency and isolation before implementing or refactoring TestFx tests, lifecycle code, helpers, shared-state declarations, or production paths those tests exercise. Use before narrowing DoNotParallelize or ResourceLock, changing parallelization settings, or introducing asynchronous workers; repeat against the final diff.","在实现或重构 TestFx 测试、生命周期代码、辅助函数、共享状态声明，或这些测试所覆盖的生产代码路径之前，检查并发性与隔离性。在缩小 DoNotParallelize 或 ResourceLock 的使用范围、更改并行化设置或引入异步工作线程之前使用；并针对最终 diff 重复检查。","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftestfx\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftestfx-parallel-safety-preflight\u002FSKILL.md",[140,141],{"categoryNo":107,"categoryName":108,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":110,"categoryName":111,"taxonomyType":28,"taxonomyTypeDesc":29},[143,130,144,119,145,146,122,147,91,148,92,149,150,151,152,153,154,155,125,156],"testfx parallel safety preflight","preflight","shared","asynchronous","exercise","concurrency","paths","isolation","helpers","diff","parallelization","lifecycle","tests","workers",{"skillNo":158,"name":159,"nameZh":160,"description":161,"descriptionZh":162,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":163,"categories":164,"keywords":167,"publishedAt":42},"01M699HC61ZV9GJ2C8JV03951G","testfx-localization-validation","TestFx 本地化校验","Validate generated TestFx localization catalogs, resource IDs, placeholders and locked tokens. Use for RESX\u002FXLF changes, OneLoc PRs, localization build failures, duplicate targets or units, and orphaned translation entries.","验证生成的 TestFx 本地化目录、资源 ID、占位符和锁定标记。适用于 RESX\u002FXLF 变更、OneLoc PR、本地化构建失败、重复的目标文本或翻译单元，以及孤立的翻译条目。","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftestfx\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftestfx-localization-validation\u002FSKILL.md",[165,166],{"categoryNo":107,"categoryName":108,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":110,"categoryName":111,"taxonomyType":28,"taxonomyTypeDesc":29},[168,169,170,171,172,173,174,175,176,123,87,125,177,178,80,179,32],"testfx localization validation","validation","localization","validate","translation","ids","for","tokens","entries","units","duplicate","targets",{"skillNo":181,"name":182,"nameZh":183,"description":184,"descriptionZh":185,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":186,"categories":187,"keywords":190,"publishedAt":42},"01M699H9J2NWQXE4BDT6R0FH7S","testfx-acceptance-validation","TestFx 验收验证","Validate TestFx shipping paths and capable CI execution using packed consumers, package\u002Fcache provenance, exact exits and artifacts, and selected-versus-executed test evidence. Use for acceptance regressions, package\u002FMSBuild\u002Flauncher\u002Fprotocol changes, or skipped-only CI results; not for unrelated unit-only or documentation changes.","使用打包后的消费者、包与缓存来源、精确的退出码和产物，以及选中测试与实际执行测试的证据，验证 TestFx 的交付路径及有效的 CI 执行。适用于验收回归、包\u002FMSBuild\u002F启动器\u002F协议变更，或仅有跳过测试的 CI 结果；不适用于无关的纯单元测试或文档变更。","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftestfx\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftestfx-acceptance-validation\u002FSKILL.md",[188,189],{"categoryNo":107,"categoryName":108,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":110,"categoryName":111,"taxonomyType":28,"taxonomyTypeDesc":29},[191,192,169,113,34,116,193,194,37,124,195,125,196,197,198,199,200,201,202,203,204,205,149,174],"testfx acceptance validation","acceptance","launcher","ci","package","cache","artifacts","provenance","documentation","unrelated","shipping","results","protocol","unit","ci results",{"skillNo":207,"name":208,"nameZh":209,"description":210,"descriptionZh":211,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":212,"categories":213,"keywords":218,"publishedAt":42},"01M699H70BB999BT4F627T1PHE","session-delivery-hygiene","会话交付规范管控","Gate local-session scope, persistent delivery, live PR state, integration provenance, and owned cleanup. Use before implementing guidance changes, changing or pushing PR work, diagnosing package\u002Foutput mismatches, or handing off implementation.","把控本地会话范围、持久化交付、实时 PR 状态、集成来源以及责任范围内的清理工作。在实施指导变更、修改或推送 PR、诊断包与产物不匹配，或交接实现工作之前使用。","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftestfx\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fsession-delivery-hygiene\u002FSKILL.md",[214,215],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":216,"categoryName":217,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BR5V701HCN066VEP7H4812","代码仓库协作管理",[219,220,221,222,223,122,84,224,225,96,226,195,125,198,227,228,80,229,230,231],"session delivery hygiene","delivery","session","hygiene","scope","cleanup","work","pr","output","state","integration","guidance","gate"]