MsBuild run Exec for every item in a list
msbuild
Solution
Simply need to use `%(scriptItems.Identity)` to get an item name from the metadata. This is well documented at MSDN.
Problem
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).