msbuild-antipatterns

Detect and fix MSBuild anti-patterns in .csproj, .props, and .targets files.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? MSBuild project and build files often accumulate subtle authoring mistakes—unquoted conditions, hardcoded paths, missing incremental-build metadata, redundant references—that cause broken builds, slow no-op builds, and flaky parallel-build failures. This Skill provides a numbered catalog of 23 anti-patterns, each with a symptom, an explanation of the impact, and a concrete BAD→GOOD fix. ## Core Features & Use Cases - Anti-Pattern Detection: Scan .csproj, .vbproj, .fsproj, .props, .targets, and Directory.Build.props/.targets files for 23 cataloged issues with severity ratings (Error, Warning, Style). - Concrete Fixes: Every entry includes a BAD→GOOD XML transformation, covering Exec misuse, condition quoting, PrivateAssets, Central Package Management, Inputs/Outputs, and ProjectReference instance forking. - Use Case: When a CI build intermittently fails with file-lock errors, use the catalog to identify AP-22/AP-23 (path-neutral global properties forking a second project instance that races the same bin/obj output) and apply the single-instance fix. ## Quick Start Review my Directory.Build.props and all .csproj 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 review a .csproj file for common MSBuild mistakes?▼

Scan the project file against the anti-pattern catalog: check for unquoted conditions, hardcoded absolute paths, manual Compile listings in SDK-style projects, Reference with HintPath instead of PackageReference, and missing PrivateAssets on analyzer packages. Each pattern includes a concrete fix.

Why does my MSBuild target run on every build even when nothing changed?▼

Custom targets without Inputs and Outputs attributes always execute because MSBuild cannot determine up-to-date state. Add Inputs including $(MSBuildProjectFile) and Outputs pointing to files under $(IntermediateOutputPath), plus FileWrites registration so dotnet clean removes generated files.

Why do I get file-lock errors during parallel dotnet builds?▼

A common cause is forking a second project instance via the MSBuild task or SetTargetFramework metadata with path-neutral global properties, so two instances share the same bin/obj output and write files concurrently. Remove the redundant global property or give each instance a distinct output path.

Do backslashes in MSBuild Import paths break on Linux or macOS?▼

No for Import paths—MSBuild's evaluator normalizes backslashes to forward slashes on Unix, so it is only a style issue. Backslashes are a real error only in raw shell strings like Exec commands, which are passed verbatim to bash and treated as escape characters.

When should I not use this MSBuild anti-pattern catalog?▼

Do not use it for non-MSBuild build systems such as npm, Maven, or CMake, and do not use it to migrate legacy projects to SDK-style format—that scenario belongs to a modernization-focused skill. It also does not execute builds; it only reviews file authoring.