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).
Simply need to use %(scriptItems.Identity)
to get an item name from the metadata. This is well documented at MSDN.
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