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
In addition to the generic Item element, ItemGroup allows child elements that represent types of items, such as Reference , ProjectReference , Compile , and others as listed at Common MSBuild project items.
An item group is a collection of products which share similar attributes like color, production, features, or usage. Item groups can also be formed based on the markets in which they're sold or if they're similar in price.
A target element can have both Inputs and Outputs attributes, indicating what items the target expects as input, and what items it produces as output. If all output items are up-to-date, MSBuild skips the target, which significantly improves the build speed. This is called an incremental build of the target.
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.
What's New in MSBuild 15
Item
Element outside targets has a newUpdate
attribute. Also, the restriction on theRemove
attribute has been eliminated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With