extension-points

Diagnose and fix MSBuild import hooks, wildcard imports, and NuGet build extension layouts.

Updated Jul 12, 2026
One-click install
npx skills add https://github.com/Patrick-Rex/DotNetTechSamples --skill extension-points-patrick-rex
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: extension-points
Source: https://github.com/Patrick-Rex/DotNetTechSamples/tree/main/.agents/plugins/dotnet-msbuild/skills/extension-points
Command: npx skills add https://github.com/Patrick-Rex/DotNetTechSamples --skill extension-points-patrick-rex

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? MSBuild extensibility relies on subtle conventions—CustomBefore/CustomAfter hooks, wildcard import directories, control properties, and NuGet build/buildTransitive layouts—where small mistakes silently drop imports, break fresh clones, or fail transitive consumers with MSB4019. This Skill provides the reference knowledge to diagnose and fix these extension-point patterns correctly. ## Core Features & Use Cases - Hook and Import Patterns: Explains CustomBefore/CustomAfter hooks, alphabetic wildcard import ordering, Exists() guards, and the MicrosoftCommonPropsHasBeenImported guard pattern. - NuGet Build Extensions: Covers build/ vs buildTransitive/ layouts, package-ID filename matching, per-TFM forwarding chains, and how nuspec/PackagePath mappings reshape source trees at pack time. - Use Case: A NuGet package's transitive consumers fail with MSB4019 because a buildTransitive forwarder dropped the TFM segment. Use this Skill to identify the missing folder segment and write a correct forwarder that derives the TFM from the file's own directory. ## Quick Start Ask the assistant to review your Directory.Build.props or NuGet package build files for MSBuild extension-point anti-patterns such as missing Exists() guards or overwritten CustomBefore properties.

Frequently Asked Questions about extension-points

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

FAQPage Schema
How do I inject custom logic into the MSBuild pipeline?

Append your .targets file path to the CustomBeforeMicrosoftCommonTargets or CustomAfterMicrosoftCommonTargets properties using a semicolon separator. Always append rather than overwrite, and guard the import with an Exists() check so missing files do not break the build.

What is the difference between build and buildTransitive in NuGet packages?

The build/ folder affects only direct consumers of a NuGet package, while buildTransitive/ propagates through the entire dependency chain. File names inside these folders must exactly match the package ID or the import is silently skipped.

Why does my NuGet buildTransitive import fail with MSB4019?

MSB4019 occurs when a buildTransitive/<tfm>/ forwarder omits the TFM segment while build/ is packed per-TFM, resolving to a non-existent package-root path. Derive the TFM segment from the file's own folder, never from $(TargetFramework).

How do I disable Directory.Build.props auto-discovery in MSBuild?

Set the ImportDirectoryBuildProps property to false to disable Directory.Build.props auto-discovery. Similar control properties exist for targets, NuGet-generated props/targets in obj/, and machine-level ImportBefore/ImportAfter wildcards.

Why are my nested Directory.Build.props settings being lost?

MSBuild only discovers the nearest Directory.Build.props by walking up the directory tree, so nested files do not automatically inherit repo-root settings. Explicitly import the parent file using GetPathOfFileAbove with a non-empty condition check.