msbuild-antipatterns
하는 일
이 스킬은 MSBuild 프로젝트 파일을 흔한 실수 목록과 비교해 검토합니다. 예를 들어 기본 제공 빌드 작업으로 해야 할 셸 명령이 있습니다. 어수선하거나 위험한 프로젝트 파일을 정리하려는 개발자를 위한 스킬입니다.
사용하는 경우
- ✓.csproj, .props, .targets 파일의 흔한 빌드 실수를 검토하고 싶을 때.
- ✓프로젝트 파일에 표준 빌드 단계로 바꿀 수 있는 사용자 정의 명령이 많을 때.
- ✓릴리스 전에 빌드 파일 개선 목록을 우선순위와 함께 받고 싶을 때.
스킬 링크
https://github.com/dotnet/skills/blob/main/plugins/dotnet-msbuild/skills/msbuild-antipatterns/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“제 프로젝트 파일을 검토해서 어떤 MSBuild 습관이 위험한지 알려 주고, 각 항목마다 수정 방법도 알려 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트가 파일을 읽고, 각 부분을 알려진 실수 목록과 대조하며, 우선순위가 매겨진 발견 사항과 각각의 수정 방법을 반환합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
MSBuild Anti-Pattern Catalog
A numbered catalog of common MSBuild anti-patterns. Each entry follows the format:
- Smell: What to look for
- Why it's bad: Impact on builds, maintainability, or correctness
- Fix: Concrete transformation
Use this catalog when scanning project files for improvements.
Review output contract
For review, audit, maintainability, or correctness-risk requests:
- Do not edit files unless the user explicitly asks for fixes.
- Return prioritized findings grounded in the supplied file, with impact and a targeted recommendation.
- Separate confirmed defects from conditional risks and already-correct patterns.
- Keep the final answer as the review; do not replace it with a terse summary of changes.
AP-01: <Exec> for Operations That Have Built-in Tasks
Smell: <Exec Command="mkdir ..." />, <Exec Command="copy ..." />, <Exec Command="del ..." />
Why it's bad: Built-in tasks are cross-platform, support incremental build, emit structured logging, and handle errors consistently. <Exec> is opaque to MSBuild.
<!-- BAD -->
<Target Name="PrepareOutput">
<Exec Command="mkdir $(OutputPath)logs" />
<Exec Command="copy config.json $(OutputPath)" />
<Exec Command="del $(IntermediateOutputPath)*.tmp" />
</Target>
<!-- GOOD -->
<Target Name="PrepareOutput">
<MakeDir Directories="$(OutputPath)logs" />
<Copy SourceFiles="config.json" DestinationFolder="$(OutputPath)" />
<Delete Files="@(TempFiles)" />
</Target>
Built-in task alternatives:
| Shell Command | MSBuild Task |
|---|---|
mkdir |
<MakeDir> |
copy / cp |
<Copy> |
del / rm |
<Delete> |
move / mv |
<Move> |
echo text > file |
<WriteLinesToFile> |
touch |
<Touch> |
xcopy /s |
<Copy> with item globs |
AP-02: Unquoted Condition Expressions
Smell: Condition="$(Foo) == Bar" — either side of a comparison is unquoted.
Why it's bad: If the property is empty or contains spaces/special characters, the condition evaluates incorrectly or throws a parse error. MSBuild requires single-quoted strings for reliable comparisons.
<!-- BAD -->
<PropertyGroup Condition="$(Configuration) == Release">
<Optimize>true</Optimize>
</PropertyGroup>
<!-- GOOD -->
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<Optimize>true</Optimize>
</PropertyGroup>
Rule: Always quote both sides of == and != comparisons with single quotes.
AP-03: Hardcoded Absolute Paths
Smell: Paths like C:\tools\, D:\packages\, /usr/local/bin/ in project files.
Why it's bad: Breaks on other machines, CI environments, and other operating systems. Not relocatable.
<!-- BAD -->
<PropertyGroup>
<ToolPath>C:\tools\mytool\mytool.exe</ToolPath>
</PropertyGroup>
<Import Project="C:\repos\shared\common.props" />
<!-- GOOD -->
<PropertyGroup>
<ToolPath>$(MSBuildThisFileDirectory)tools\mytool\mytool.exe</ToolPath>
</PropertyGroup>
<Import Project="$(RepoRoot)eng\common.props" />
Preferred path properties:
| Property | Meaning |
|---|---|
$(MSBuildThisFileDirectory) |
Directory of the current .props/.targets file |
$(MSBuildProjectDirectory) |
Directory of the .csproj |
$([MSBuild]::GetDirectoryNameOfFileAbove(...)) |
Walk up to find a marker file |
$([MSBuild]::NormalizePath(...)) |
Combine and normalize path segments |
AP-04: Restating SDK Defaults
Smell: Properties set to values that the .NET SDK already provides by default.
Why it's bad: Adds noise, hides intentional overrides, and makes it harder to identify what's actually customized. When defaults change in newer SDKs, the redundant properties may silently pin old behavior.
<!-- BAD: All of these are already the default -->
<PropertyGroup>
<OutputType>Library</OutputType>
<EnableDefaultItems>true</EnableDefaultItems>
<EnableDefaultCompileItems>true</EnableDefaultCompileItems>
<RootNamespace>MyLib</RootNamespace> <!-- matches project name -->
<AssemblyName>MyLib</AssemblyName> <!-- matches project name -->
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<!-- GOOD: Only non-default values -->
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
AP-05: Manual File Listing in SDK-Style Projects
Smell: <Compile Include="File1.cs" />, `<Compile Inc
자주 묻는 질문
프로젝트를 자동으로 바꾸나요?
아니요. 수정 적용을 요청하지 않는 한 검토는 발견 사항만 제공합니다.
오래된 프로젝트를 변환하는 용도인가요?
아니요. 오래된 프로젝트를 최신 형식으로 바꾸는 일은 현대화 스킬이 다룹니다.
어떤 종류의 실수를 다루나요?
예를 들어 기본 제공 MSBuild 작업이 더 잘 처리하는 일에 Exec를 쓰는 경우가 있습니다.
상세 정보
작성자의 원본 설명
DO NOT INVOKE when the primary request explicitly asks to convert, migrate, modernize, or rewrite a legacy/old-style project to SDK style; use msbuild-modernization. Migration prompts often mention ToolsVersion, explicit Compile/Reference entries, packages.config, or Microsoft.CSharp.targets, but merely reviewing or auditing a file that contains those patterns remains in scope here. USE FOR broad review, audit, lint, or maintainability/correctness checks of project/build files, including custom targets; prioritized cross-cutting findings; discrete anti-patterns; F# ordering/FS0039; cross-platf
repo: dotnet/skills
인기도
- GitHub 스타
- 5.8k
- 순위
- #14604
- 라이선스
- MIT
- 업데이트
- 2026. 11. 2.
댓글
- …
이 저장소의 다른 스킬
create-custom-agent
5.8k에이전트가 자체 도구, 지침, 다른 에이전트로의 핸드오프를 가진 VS Code 커스텀 에이전트 파일을 만들도록 돕습니다.
create-skill
5.8k에이전트가 올바른 이름, 명확한 트리거 설명, 표준을 따르는 SKILL.md 파일로 새 에이전트 스킬을 만들도록 돕습니다.
csharp-scripts
5.8k에이전트가 .NET 명령줄 도구로 작은 C# 프로그램을 전체 프로젝트 없이 단일 파일로 실행하도록 돕습니다.
dotnet-pinvoke
5.8k에이전트가 .NET에서 네이티브 C나 C++ 라이브러리를 올바르게 호출하도록 돕습니다. 시그니처, 문자열 처리, 메모리, 안전 핸들을 다룹니다.
비슷한 스킬
openclaw-update
394k에이전트가 설치 방식에 맞는 방법을 골라 기존 OpenClaw Gateway를 업데이트하고, 세션이 계속 작동하도록 돕습니다.
diagnose-gateway
394k에이전트가 설정, 채널, 포트를 확인해 OpenClaw Gateway가 왜 실패하는지 찾되, 아무것도 바꾸지 않도록 돕습니다.
crabbox-apps
394k에이전트가 임시 클라우드 머신에서 앱을 열고 실행한 뒤, 그 화면을 채팅의 측면 패널에 보여 주도록 돕습니다.