tags:

views:

108

answers:

1

I'm trying to load a list of filenames from a text file and then run an Exec task for each entry retrieved from the text file.

So I have a file, let's call it SomeFile.txt containing the following:

FileA.file
FileB.file
FileC.file

The MsBuild code I have for this looks like this (which doesn't work:)

<Target Name="runScripts">  

    <ItemGroup>
        <scriptsFile Include="SomeFile.txt" />
    </ItemGroup>        

    <ReadLinesFromFile File="@(scriptsFile)">
        <Output TaskParameter="Lines" ItemName="scriptItems" />
    </ReadLinesFromFile>

    <Message Text="Running Exec for each entry..." />           
    <Exec Command="$(someCommand) %(scriptItems)" />

</Target>

This gives me an error saying I need to specify an item name, but if I use anything like %(scriptItems.item) or %(itemname.scriptItems) MsBuild simply puts a blank instead of %(scriptItems).

+2  A: 

Ok, I figured it out

Simply need to use

%(scriptItems.Identity)

Jaco Pretorius