Langsung ke konten
Skillpedia
Deploy & cloud (DevOps)5.8k ยท #14603

item-management

Fungsinya

Skill ini memeriksa daftar item MSBuild, yaitu kelompok file dan referensi yang dipakai build, lalu memperbaiki kesalahan cara item ditambahkan, dihapus, atau diubah. Skill ini untuk pengembang yang melihat file yang salah di build atau perilaku yang tidak bisa mereka jelaskan.

Kapan dipakai

  • โœ“Saat build menyertakan atau melewatkan file karena aturan Include, Remove, atau Update.
  • โœ“Saat item memiliki entri ganda atau tumpang tindih yang mengubah perilaku build.
  • โœ“Saat Anda ingin tinjauan atas cara item group dan metadata sebuah proyek ditulis.

Link skill

https://github.com/dotnet/skills/blob/main/plugins/dotnet-msbuild/skills/item-management/SKILL.md

Salin 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

Gunakan skill ini untuk membantu saya: https://github.com/dotnet/skills/blob/main/plugins/dotnet-msbuild/skills/item-management/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit โ†’

Contoh permintaan ke AI

โ€œBuild .NET saya menyertakan file yang seharusnya dilewati. Bisakah Anda memeriksa aturan Include dan Remove di proyek saya?โ€

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Agent membaca item group di proyek, menelusuri bagaimana setiap aturan menambah, menghapus, atau memperbarui item, lalu menunjukkan di mana hasilnya berbeda dari yang dimaksudkan.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.

MSBuild Item Management Patterns

Canonical patterns for working with item groups, from Microsoft.Common.CurrentVersion.targets.

Include / Remove / Update โ€” Three Operations

Operation Purpose When to use
Include Add new items to the group Creating items with identity + metadata
Remove Remove items matching a pattern Excluding files or clearing a group
Update Modify metadata on existing items Adding/changing metadata without re-adding

Include โ€” Add Items

<ItemGroup>
  <Compile Include="Generated\*.cs">
    <AutoGen>true</AutoGen>
  </Compile>
</ItemGroup>

Remove โ€” Subtract Items

<ItemGroup>
  <!-- Remove specific items -->
  <Reference Remove="$(AdditionalExplicitAssemblyReferences)" />

  <!-- Set subtraction: prior minus current -->
  <_CleanOrphanFileWrites Include="@(_CleanPriorFileWrites)"
      Exclude="@(_CleanCurrentFileWrites)" />

  <!-- Clear an entire group -->
  <_Temporary Remove="@(_Temporary)" />
</ItemGroup>

Update โ€” Modify Existing Items

<ItemGroup>
  <EmbeddedResource Update="@(EmbeddedResource)"
      Condition="'%(NuGetPackageId)' == 'Microsoft.CodeAnalysis.Collections'">
    <GenerateSource>true</GenerateSource>
    <ClassName>Microsoft.CodeAnalysis.Collections.SR</ClassName>
  </EmbeddedResource>
</ItemGroup>

Update does not add items โ€” it only modifies items already in the group.

Item Batching โ€” %(Metadata)

When %(Metadata) appears in target attributes or task parameters, MSBuild batches execution per unique metadata value.

Target-level batching (Outputs)

<Target Name="GenerateSatelliteAssemblies"
    Inputs="$(MSBuildAllProjects);@(_SatelliteAssemblyResourceInputs)"
    Outputs="$(IntermediateOutputPath)%(Culture)\$(TargetName).resources.dll">
  <!-- Runs once per unique Culture value -->
</Target>

Task-level batching

<Copy SourceFiles="@(_SourceItems)"
    DestinationFiles="@(_SourceItems->'$(OutDir)%(TargetPath)')">
</Copy>

Per-item filtering with Condition

<ItemGroup>
  <_ResxOutput Include="@(EmbeddedResource->'%(OutputResource)')"
      Condition="'%(EmbeddedResource.WithCulture)' == 'false'" />
</ItemGroup>

Batching rules

  • %(Metadata) in Condition or Outputs โ†’ target batches per unique value.
  • %(Metadata) in task parameters โ†’ task batches per unique value.
  • Do not mix %() from different item groups in the same expression โ€” this causes a cross-product (see Common Pitfalls).

Item Transforms โ€” @(Item->'expression')

Transforms create new item lists by applying an expression to each item:

<!-- Transform file paths to destinations -->
<Copy SourceFiles="@(IntermediateAssembly)"
    DestinationFiles="@(IntermediateAssembly->'$(OutDir)%(Filename)%(Extension)')"/>

<!-- Transform with separator for display -->
<Message Text="Files: @(Compile->'%(Filename)', ', ')" />

Exclude Pattern โ€” Set Subtraction on Include

<ItemGroup>
  <Compile Include="**\*.cs" Exclude="Generated\**;Tests\**" />
</ItemGroup>

Exclude only works on Include โ€” it cannot be used with Update or Remove.

Conditional Item Inclusion

<!-- Condition on ItemGroup โ€” all or nothing -->
<ItemGroup Condition="'$(NetCoreBuild)' == 'true'">
  <PackageReference Include="System.IO.Pipelines" />
</ItemGroup>

<!-- Condition on individual items -->
<ItemGroup>
  <PackageReference Include="System.IO.Pipelines"
      Condition="'$(NetCoreBuild)' == 'true'" />
</ItemGroup>

PrivateAssets on Tool/Analyzer Packages

<ItemGroup>
  <PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" PrivateAssets="all" />
  <PackageReference Include="StyleCop.Analyzers" PrivateAssets="all" />
</ItemGroup>

Common Pitfalls

Cross-product batching

Referencing %(Metadata) from two different item groups creates O(Nร—M) executions:

<!-- BAD: Cross-product of @(Source) ร— @(Config) -->
<Exec Command="process %(Source.Identity) with %(Config.Identity)" />

<!-- GOOD: Reference one group via batching, the other via property -->
<Exec Command="process %(Source.Identity) with $(ConfigFile)" />

Generated files in source tree

Write to $(IntermediateOutputPath) (obj/), not the source directory. Source-tree generation pollutes version control and can cause duplicate compilation via globs.

Missing FileWrites

Every file created during a target must be added to `@(FileWrite

Pertanyaan umum

Apakah skill ini mengubah file proyek saya?

Permintaan tinjauan menghasilkan temuan dan rekomendasi. Agent hanya mengubah file jika Anda memintanya menerapkan perbaikan.

Apa beda Update dengan Include?

Update mengubah metadata pada item yang sudah ada, sedangkan Include menambahkan item baru ke grup.

Apakah skill ini mencakup masalah properti build?

Tidak. Cacat properti dicakup oleh skill terpisah.

Detail

Deskripsi asli dari pembuat

Own concrete MSBuild ItemGroup and item-expression questions. USE FOR: Include, Remove, Update, item identity and metadata, transforms, filtering, batching, duplicate or overlapping items, and reviews that verify whether those operations are correct. Generated items stay in scope when the central defect is item identity, metadata, batching, duplicate declarations, or glob/Remove/Update semantics. For a generated artifact missing from compilation or output, wrong target timing/path, or FileWrites clean tracking without a broader item-semantics defect, use including-generated-files. The item ope

repo: dotnet/skills

Popularitas

Bintang GitHub
5.8k
Peringkat
#14603
Lisensi
MIT
Diperbarui
2/11/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • โ€ฆ

Skill lain dari repositori ini

Skill serupa