msbuild-antipatterns

Detects and fixes common anti-patterns in MSBuild project files with BAD-to-GOOD transformations.

1|Updated Apr 1, 2026
One-click install
npx skills add https://github.com/AlahmadiQ8/sre-agent-demo --skill msbuild-antipatterns-alahmadiq8
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: msbuild-antipatterns
Source: https://github.com/AlahmadiQ8/sre-agent-demo/tree/main/.claude/skills/msbuild-antipatterns
Command: npx skills add https://github.com/AlahmadiQ8/sre-agent-demo --skill msbuild-antipatterns-alahmadiq8

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? MSBuild project files (.csproj, .props, .targets) accumulate subtle mistakes—unquoted conditions, hardcoded paths, redundant SDK defaults, scattered package versions—that break cross-platform builds, slow incremental compilation, and create maintenance debt. This Skill provides a numbered catalog of 21 anti-patterns so reviewers can systematically audit and clean up build files. ## Core Features & Use Cases - 21 Cataloged Anti-Patterns: Each entry includes a smell to look for, an explanation of why it is harmful, and a concrete BAD-to-GOOD XML transformation. - Severity-Ranked Checklist: A quick-reference table orders checks from error-prone issues (unquoted conditions, side effects during evaluation) down to stylistic noise. - Deep-Dive References: Supplementary documents cover incremental build Inputs/Outputs, PrivateAssets for analyzer packages, and evaluation-phase pitfalls like conditioning properties on TargetFramework in .props files. - Use Case: While reviewing a pull request that adds a new .csproj, scan it against the catalog to catch a HintPath-based reference, missing PrivateAssets on StyleCop.Analyzers, and an unquoted Configuration condition before merge. ## Quick Start Review my .csproj and Directory.Build.props files for MSBuild anti-patterns and suggest fixes.

Frequently Asked Questions about msbuild-antipatterns

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

FAQPage Schema
How do I find anti-patterns in my .csproj files?

Scan project files against the catalog's quick-reference checklist, starting with high-severity items like unquoted conditions and hardcoded absolute paths. Each anti-pattern lists a concrete smell to search for, such as Exec tasks for file copies or manual Compile item listings in SDK-style projects.

What are common MSBuild mistakes in .NET projects?

Common mistakes include using Exec instead of built-in tasks like Copy and MakeDir, restating SDK defaults, referencing NuGet packages via HintPath, missing PrivateAssets on analyzer packages, and scattering package versions without Central Package Management.

Why does my TargetFramework condition not work in Directory.Build.props?

TargetFramework is not reliably set when .props files are evaluated for single-targeting projects, so property conditions on it silently fail. Move the condition to Directory.Build.targets or the project file itself; item and target conditions in .props files are unaffected.

Should I use Exec or built-in MSBuild tasks for file operations?

Use built-in tasks like MakeDir, Copy, Delete, and WriteLinesToFile instead of Exec shell commands. Built-in tasks are cross-platform, support incremental build, emit structured logging, and handle errors consistently.

When should this anti-pattern catalog not be used?

Do not apply it to non-MSBuild build systems like npm, Maven, or CMake, since every rule is specific to MSBuild XML semantics. For migrating legacy projects to SDK-style format, use a dedicated modernization workflow instead.