Is there a way to remove the contents of an ItemGroup without resorting to Targets? I'm looking for something equivalent to:
<ItemGroup>
<MyItemGroup Remove="@(MyItemGroup)"/>
</ItemGroup>
Thanks
Is there a way to remove the contents of an ItemGroup without resorting to Targets? I'm looking for something equivalent to:
<ItemGroup>
<MyItemGroup Remove="@(MyItemGroup)"/>
</ItemGroup>
Thanks
No, as the documentation states, Remove can only be included in a ItemGroup inside a Target. I'm not sure why using a Target is an issue in your case, but if want to use the 'Remove' step for every build config, then add it to one of the BeforeXXXX AfterXXX hooks, like BeforeBuild.
ItemGroup 'Remove' Documentation
Starting in the .NET Framework 3.5, Target elements may contain ItemGroup elements that may contain item elements. These item elements can contain the Remove attribute, which removes specific items (files) from the item type. For example, the following XML removes every .config file from the Compile item type.
<Target>
<ItemGroup>
<Compile Remove="*.config"/>
</ItemGroup>
</Target>
Now there is.
Item
Element outside targets has a newUpdate
attribute. Also, the restriction on theRemove
attribute has been eliminated.