icn
icn

Reputation: 17876

Msbuild Custom Task - For loop

I would like to implement a Msbuild Custome task to loop a list of items and do something about each item. Basically I would liketo build a foreach or for loop in msbuild.

I have searched around but didn't find much useful information about output a list of items and loop though each of them

What I got

How to implement Custom Tasks http://blogs.msdn.com/b/msbuild/archive/2006/01/21/515834.aspx

Return output from a custom msbuild task

Return output from an MsBuild task?

Is it possible to implement my though with msbuild custom task?

Update:

I would like something

<Foreach item='String' in="PropertyGroups" Property='MyPropertyName'>
   //do what ever to use $(MypropertyName) for other tasks
</Foreach>

Upvotes: 1

Views: 652

Answers (1)

Ritch Melton
Ritch Melton

Reputation: 11598

Standard MSBuild tasks operate on collections (ItemGroup in MSBuild-ese, ITaskItem[] in the ITask interface) and custom tasks can do the same. You don't need a foreach.

Your task, if you need a custom task, would look like this:

<MyTask TaskItems="@(blah)"/>

Upvotes: 2

Related Questions