Remove Items From ItemGroups In MSBuild

The ability to remove entries from ItemGroups is one of the new features of MSBuild 3.5.

To remove an Item from an ItemGroup in MSBuild 2.0 you would have to create a new ItemGroup from the old one and skip the Item that you needed removed.

In MSBuild 3.5 we can achieve it by using the Remove parameter.

Example:

<ItemGroup>    <Files Include="a.cs" />    <Files Include="b.cs" />    <Files Include="c.cs" />    <Files Include="d.cs" />    <Files Include="e.cs" />    <Files Include="f.cs" />    <Files Include="g.cs" /></ItemGroup>

Some times we want to restrict some data from this group in a target. In order to do it,  we should use the Remove parameter:

<ItemGroup>    <Files Remove="a.cs" />    <Files Remove="e.cs" />    <Files Remove="f.cs" /></ItemGroup>

Read more at msdn.

Advertisements

One Response to Remove Items From ItemGroups In MSBuild

  1. maord says:

    This comment originally written by:The ability to remove entries from ItemGroups is one of the new features of MSBuild 3.5. To remove an Item from an ItemGroup in MSBuild 2.0 you would have to create a new ItemGroup from the old one and skip the Item that you needed removed. In MSBuild

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: