target-authoring

Diagnoses and fixes custom MSBuild target authoring anti-patterns using canonical SDK patterns.

1|Updated Jun 1, 2026
One-click install
npx skills add https://github.com/D1ssolve/craft-agents --skill target-authoring-d1ssolve
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: target-authoring
Source: https://github.com/D1ssolve/craft-agents/tree/main/skills/target-authoring
Command: npx skills add https://github.com/D1ssolve/craft-agents --skill target-authoring-d1ssolve

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Custom MSBuild targets often break silently: overwritten dependency chains drop SDK targets, query targets return stale results, and missing Inputs/Outputs cause unnecessary rebuilds. This Skill provides canonical patterns from Microsoft.Common.CurrentVersion.targets to author and review custom targets correctly. ## Core Features & Use Cases - Target Chain Patterns: Explains the Build→CoreBuild three-level pattern, DependsOnTargets vs BeforeTargets vs AfterTargets, and the $(XxxDependsOn) chain-extension convention. - Anti-Pattern Diagnosis: Detects broken SDK target chains (e.g., Directory.Build.targets redefining SDK targets), CompileDependsOn overwrites, and Returns vs Outputs misuse in query targets. - Complete Target Template: Provides a full custom target skeleton with validation targets, empty extensibility hooks, Inputs/Outputs incrementality, and FileWrites registration for clean tracking. - Use Case: A team's Directory.Build.targets silently replaces $(CompileDependsOn), dropping SDK code generation targets. Use this Skill to identify the overwrite and rewrite it as an append to the existing chain. ## Quick Start Review my custom MSBuild target in Directory.Build.targets and fix any chain-extension or incrementality anti-patterns.

Frequently Asked Questions about target-authoring

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a custom target to the MSBuild compile pipeline?

Append your target to the existing dependency property, for example setting CompileDependsOn to $(CompileDependsOn);MyCodeGenTarget. Never overwrite the property, since that silently drops SDK targets from the chain.

What is the difference between DependsOnTargets, BeforeTargets, and AfterTargets in MSBuild?

DependsOnTargets declares prerequisites a target explicitly requires. BeforeTargets and AfterTargets inject your target into a pipeline you do not own, such as running validation before CoreCompile without modifying SDK files.

Why does my MSBuild query target return stale results?

Query targets like GetTargetPath should use Returns, not Outputs. Outputs triggers timestamp-based up-to-date checks, so MSBuild skips the target and returns cached data instead of fresh results.

Should custom MSBuild targets go in .props or .targets files?

Custom targets belong in .targets files. Targets defined in .props load too early, so BeforeTargets hooks on SDK targets have nothing to attach to yet and silently never run.

How do I make a custom MSBuild target incremental?

Add Inputs and Outputs attributes to the core target so MSBuild compares timestamps and skips up-to-date work. Also register generated files in the FileWrites item so Clean removes them correctly.