msbuild-antipatterns
Fungsinya
Skill ini meninjau file MSBuild terhadap daftar kesalahan umum, seperti perintah shell yang sebaiknya diganti dengan task bawaan. Skill ini untuk pengembang yang ingin membersihkan file proyek yang berantakan atau berisiko.
Kapan dipakai
- ✓Saat Anda ingin meninjau file .csproj, .props, atau .targets untuk kesalahan build umum.
- ✓Saat file proyek punya banyak perintah kustom yang bisa diganti langkah build standar.
- ✓Saat Anda ingin daftar perbaikan file build berprioritas sebelum rilis.
Link skill
https://github.com/dotnet/skills/blob/main/plugins/dotnet-msbuild/skills/msbuild-antipatterns/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
“Tinjau file proyek saya dan beri tahu kebiasaan MSBuild mana yang berisiko, beserta perbaikan untuk masing-masing.”
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Agent membaca file, mencocokkan setiap bagian dengan katalog kesalahan yang diketahui, lalu mengembalikan temuan berprioritas beserta perbaikannya.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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
Pertanyaan umum
Apakah skill ini mengubah proyek saya secara otomatis?
Tidak. Tinjauan hanya mengembalikan temuan, kecuali Anda meminta perbaikan diterapkan.
Apakah ini untuk mengonversi proyek lama?
Tidak. Konversi proyek lama ke format baru dicakup oleh skill modernisasi.
Jenis kesalahan apa saja yang dicakup?
Contohnya termasuk memakai Exec untuk pekerjaan yang lebih baik ditangani task MSBuild bawaan.
Detail
Deskripsi asli dari pembuat
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
Popularitas
- Bintang GitHub
- 5.8k
- Peringkat
- #14604
- Lisensi
- MIT
- Diperbarui
- 2/11/2026
Komentar
- …
Skill lain dari repositori ini
create-custom-agent
5.8kMembantu agent Anda membuat file agen kustom VS Code dengan alatnya sendiri, instruksi, dan serah terima ke agent lain.
create-skill
5.8kMembantu agent Anda membuat skill agent baru dengan nama yang valid, deskripsi pemicu yang jelas, dan file SKILL.md yang mengikuti standar.
csharp-scripts
5.8kMembantu agent Anda menjalankan program C# kecil sebagai satu file dengan alat baris perintah .NET, tanpa membuat proyek lengkap.
dotnet-pinvoke
5.8kMembantu agent Anda memanggil pustaka native C atau C++ dari .NET dengan benar, mencakup tanda tangan, penanganan string, memori, dan safe handle.
Skill serupa
openclaw-update
394kMembantu agent Anda memperbarui OpenClaw Gateway yang sudah ada, dengan memilih metode pembaruan yang sesuai cara pemasangannya dan menjaga sesi Anda tetap berjalan.
diagnose-gateway
394kMembantu agent Anda mencari tahu mengapa OpenClaw Gateway gagal dengan memeriksa pengaturan, channel, dan port tanpa mengubah apa pun.
crabbox-apps
394kMembantu agent Anda membuka dan menjalankan aplikasi di mesin cloud sementara, lalu menampilkan tampilannya di panel samping chat Anda.