dotnet-msbuild-antipatterns

Reviews .csproj, .props, and .targets files for MSBuild antipatterns with BAD and GOOD forms.

Updated Jun 30, 2026
One-click install
npx skills add https://github.com/bsamiee/Rasm --skill dotnet-msbuild-antipatterns-bsamiee
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dotnet-msbuild-antipatterns
Source: https://github.com/bsamiee/Rasm/tree/main/.claude/skills/dotnet-msbuild-antipatterns
Command: npx skills add https://github.com/bsamiee/Rasm --skill dotnet-msbuild-antipatterns-bsamiee

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? MSBuild project files accumulate subtle mistakes—unquoted condition operands, misplaced property defaults, duplicate project instances—that cause build failures, silent wrong values, or slow maintenance. This Skill provides a numbered catalog of 29 antipatterns so reviewers can detect, prove, and correct each smell systematically. ## Core Features & Use Cases - Antipattern Catalog: 29 entries (AP-01 through AP-29) covering evaluation, placement, items and references, targets, execution and paths, and build graph, each with severity (ERROR or STYLE), the failure it causes, the rule, and paired BAD/GOOD XML forms. - Proof Commands: Each section names the verification command, such as dotnet msbuild <project> -getProperty:<Name>, -getItem:<Type>, -pp:, or binlog evaluation analysis. - Worked Examples: A references file with full-file corrections for multi-element fixes like duplicate publish instances, SetTargetFramework forms, host-supplied references, and layer validation targets. - Use Case: When reviewing a pull request that edits Directory.Build.props, check each changed property against the placement section to catch conditions on later values or unconditional overrides before they break the build. ## Quick Start Review my Directory.Build.props and all .csproj files for MSBuild antipatterns and list each violation with its fix.

Frequently Asked Questions about dotnet-msbuild-antipatterns

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

FAQPage Schema
How do I review a .csproj file for MSBuild antipatterns?▼

Check the project against the catalog sections: evaluation, placement, items, targets, paths, and build graph. Prove each suspected smell with dotnet msbuild -getProperty or -getItem, then apply the GOOD form shown beside each BAD example.

What goes in Directory.Build.props vs Directory.Build.targets?▼

Props files own overridable property defaults with empty-value conditions, since they import before the project body. Targets files own targets, item Update and Remove operations, and conditions on values like TargetFramework that the SDK sets later.

Why does my MSBuild condition on TargetFramework never match?▼

A condition in Directory.Build.props evaluates before the project body and SDK targets set TargetFramework, so it compares an empty string. Move the condition to Directory.Build.targets or after the assignment in the project file.

Can I use Exec to run dotnet build inside a target?▼

No, Exec starts a build process the engine cannot schedule or log, and BuildCheck reports BC0302. Order the project through a ProjectReference with ReferenceOutputAssembly="false" or call a target through the MSBuild task instead.

Why does WriteLinesToFile keep growing my output file?▼

WriteLinesToFile appends by default, adding one copy of Lines per build. Set Overwrite="true" and WriteOnlyWhenDifferent="true" so the file is replaced and its timestamp holds for incremental checks.

When should a ProjectReference use SetTargetFramework?▼

Use SetTargetFramework only for multi-targeting references or builds under another framework. On a single-targeting project it creates a duplicate project instance sharing one output path, causing CoreCompile to run twice.