target-authoring

Diagnose and fix custom MSBuild target authoring anti-patterns using canonical SDK patterns.

Updated Sep 22, 2026
One-click install
npx skills add https://github.com/bytecakelake/Nurse-Scheduler --skill target-authoring-bytecakelake
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: target-authoring
Source: https://github.com/bytecakelake/Nurse-Scheduler/tree/main/.agents/plugins/dotnet-msbuild/skills/target-authoring
Command: npx skills add https://github.com/bytecakelake/Nurse-Scheduler --skill target-authoring-bytecakelake

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Custom MSBuild targets often break silently: Directory.Build.targets files redefine SDK targets, CompileDependsOn chains get overwritten instead of extended, query targets return stale results from Outputs misuse, and missing Inputs/Outputs or FileWrites registration cause unnecessary rebuilds and broken incremental builds. ## Core Features & Use Cases - Chain Extension Patterns: Apply the Build→CoreBuild three-level pattern and extend $(XxxDependsOn) properties by appending rather than overwriting, preserving SDK targets. - Injection Mechanism Selection: Choose correctly between DependsOnTargets, BeforeTargets, and AfterTargets based on whether you own the target being hooked. - Returns vs Outputs Guidance: Use Returns for inter-project query targets like GetTargetPath and Outputs only for incrementality, avoiding stale query results. - Use Case: Your Directory.Build.targets silently drops SDK compile steps because it redefines CompileDependsOn. Use this Skill to rewrite it as an append to $(CompileDependsOn) and add proper Inputs/Outputs plus FileWrites registration. ## Quick Start Review my custom MSBuild target in Directory.Build.targets and fix any chain-overwriting or Returns/Outputs 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 chain?▼

Append your target to the existing CompileDependsOn property using $(CompileDependsOn);MyTarget rather than redefining it. Overwriting the property silently drops SDK targets like code generation and core compile steps.

When should I use BeforeTargets vs DependsOnTargets in MSBuild?▼

Use DependsOnTargets when your target explicitly requires prerequisites you control. Use BeforeTargets or AfterTargets when injecting into a pipeline you do not own, such as hooking CoreCompile from a NuGet package's build folder.

Why does my MSBuild query target return stale results?▼

Query targets like GetTargetPath return stale data when they declare Outputs, because MSBuild skips them as up-to-date. Use Returns instead, which specifies what callers receive without triggering timestamp-based skipping.

Why does Directory.Build.targets break my SDK build?▼

Directory.Build.targets is imported after SDK targets, so redefining properties like CompileDependsOn there silently replaces the SDK's chain. Always append with $(ExistingProperty) included, and define targets in .targets files rather than .props.

How do I make a custom MSBuild target incremental?▼

Declare Inputs and Outputs on the core target so MSBuild compares timestamps and skips up-to-date work. Also register generated files in the FileWrites item group so Clean can remove them and incremental builds stay correct.

When should I not use this target authoring guidance?▼

This guidance covers authoring patterns only, not incremental build tuning, build parallelization, or general MSBuild anti-patterns. It also does not apply to non-MSBuild build systems such as CMake or Bazel.