2

下の すべてのプロジェクト ファイルをデフォルトで にContent\**設定CopyToOutputDirectoryしたいのですが、各項目を追加する必要があります (したがって、ワイルドカード include はありません)。何かのようなもの:PreserveNewest

<ItemDefinitionGroup>
  <Content Include="Content\**\*">
    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  </Content>
</ItemDefinitionGroup>

Include残念ながら、ItemDefinition は属性をサポートしていません。私も試しました:

<ItemDefinitionGroup>
  <Content>
    <CopyToOutputDirectory Condition="$([System.String]::new('%(Identity)').StartsWith('Content\'))">PreserveNewest</CopyToOutputDirectory>
  </Content>
</ItemDefinitionGroup>

ここで提案されているようですが、ItemDefinition では機能しないようです。実際、私がこれを試みたとき:

<ItemDefinitionGroup>
  <Content>
    <CustomToolNamespace>Foo = $([System.String]::new(%(Identity)))</CustomToolNamespace>
  </Content>
</ItemDefinitionGroup>

プロパティ ペインによって報告された CustomToolNamespace の値は でしたFoo = %(Identity)

4

1 に答える 1

0

Itemgroup の新しいメタデータを作成する場合:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >
<ItemDefinitionGroup>
    <Content>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
</ItemDefinitionGroup>

<Target Name="Definition">
   <ItemGroup>
      <Content Include="Content\**\*"/>
   </ItemGroup>

   <Message Text="%(Content.CopyToOutputDirectory)"/>
</Target>
</Project>

これにより、新しいメタデータが項目グループに追加されます。

次のように、異なるインクルードとメタデータに基づいて 2 つのアイテムグループを結合することもできます。

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >
<ItemDefinitionGroup>
    <WithContent>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </WithContent>
</ItemDefinitionGroup>

<Target Name="Definition">
   <ItemGroup>
      <NotContent Include="Content\**\not*"/>
   </ItemGroup>
   <ItemGroup>
      <WithContent Include="Content\**\with*"/>
   </ItemGroup>

   <ItemGroup>
     <Content Include="@(NotContent)"/>
     <Content  Include="@(WithContent)"/>
   </ItemGroup>

   <Message Text="Added together: %(Content.CopyToOutputDirectory)"/>
   <Message Text="Added together: %(Content.Identity)"/>

</Target>
</Project>
于 2013-06-11T11:22:46.333 に答える