Agent skill · Documentation

target-authoring

Canonical patterns for writing custom MSBuild targets. USE FOR: diagnosing and fixing custom target authoring anti-patterns; broken SDK target chains across files (e.g., Directory.Build.targets silently redefining SDK targets); targets that replace CompileDependsOn instead of extending it with $(CompileDependsOn); query targets returning stale results from Outputs vs Returns misuse; missing Inputs/Outputs causing unnecessary rebuilds; missing FileWrites registration. Covers DependsOnTargets vs BeforeTargets vs AfterTargets, the Build→CoreBuild three-level pattern, and the $(XxxDependsOn) chain

dotnetgithub.com/dotnetGitHub ↗
claude-codeMIT
Install
npx skills add dotnet/skills --skill target-authoring --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 6 KB
Bundled scripts: none
Path: plugins/dotnet-msbuild/skills/target-authoring/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 4,927
Language: C#
Read our review of the source →

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# Custom Target Authoring Patterns Canonical patterns from `Microsoft.Common.CurrentVersion.targets` in the MSBuild repository. ## The Three-Level Target Chain Every major entry point (Build, Rebuild, Clean) delegates to a **property** listing its dependencies, which chains through Before → Core → After: ```xml <PropertyGroup> <BuildDependsOn> BeforeBuild; CoreBuild; AfterBuild </BuildDependsOn> </PropertyGroup> <Target Name="Build" Condition=" '$(_InvalidConfigurationWarning)' != 'true' " DependsOnTargets="$(BuildDependsOn)" Returns="@(TargetPathWithTargetPlatformMoniker)" /> <!-- Empty extensibility targets — users override these --> <Target Name="BeforeBuild" /> <Target Name="AfterBuild" /> ``` `CoreBuild` delegates to `$(CoreBuildDependsOn)` and includes error handlers: ```xml <Target Name="CoreBuild" DependsOnTargets="$(CoreBuildDependsOn)"> <OnError ExecuteTargets="_TimeStampAfterCompile;PostBuildEvent" Condition="'$(RunPostBuildEvent)' == 'Always'" /> <OnError ExecuteTargets="_CleanRecordFileWrites" /> </Target> ``` ### Rules - Delegate to a property (`DependsOnTargets="$(MyTargetDependsOn)"`), not hardcoded targets. - `OnError` goes inside the orchestrating target to ensure

What's inside
Steps it walks through
  1. The Three-Level Target Chain
  2. Rules
  3. Chain Extension — Append, Never Overwrite
  4. DependsOnTargets vs BeforeTargets vs AfterTargets
  5. Returns vs Outputs
  6. Target Naming Conventions
  7. Complete Custom Target Template
  8. Common Pitfalls
More from skills
All skills →
About this skill
What does the target-authoring skill do?

Canonical patterns for writing custom MSBuild targets. USE FOR: diagnosing and fixing custom target authoring anti-patterns; broken SDK target chains across files (e.g., Directory.Build.targets silently redefining SDK targets); targets that replace CompileDependsOn instead of extending it with $(CompileDependsOn); query targets returning stale results from Outputs vs Returns misuse; missing Inputs/Outputs causing unnecessary rebuilds; missing FileWrites registration. Covers DependsOnTargets vs BeforeTargets vs AfterTargets, the Build→CoreBuild three-level pattern, and the $(XxxDependsOn) chain

How do I install it?

Run `npx skills add dotnet/skills --skill target-authoring --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From dotnet/skills, a repository with 4,927 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going