This topic has not yet been rated - Rate this topic

ReadLinesFromFile Task

Reads a list of items from a text file.

The following table describes the parameters of the ReadLinesFromFile task.

Parameter

Description

File

Required ITaskItem parameter.

Specifies the file to read. The file must have one item on each line.

Lines

Optional ITaskItem[] output parameter.

Contains the lines read from the file.

The following example uses the ReadLinesFromFile task to create items from a list in a text file. The items read from the file are stored in the ItemsFromFile item collection.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <ItemGroup>
        <MyTextFile Include="Items.txt"/>
    </ItemGroup>

    <Target Name="ReadFromFile">
        <ReadLinesFromFile
            File="@(MyTextFile)" >
            <Output
                TaskParameter="Lines"
                ItemName="ItemsFromFile"/>
        </ReadLinesFromFile>
    </Target>

</Project>
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
format of the input file
The format of the text file is simply one item per line.  From what I can tell, there can be no comments in the file and the file does not support adding metadata to the items that are read in.
What is the format of the input file?
It may be obvious to people who already have lots of experience with MS Build, but for those of us who are just learning, documentation like this are very frustrating. So now I know that it is possible to read items from an external file. That is useful information, but now I have to go to google or trial and error to find out how the data in the input file need to be formatted.

I will come back and post an example when I find out.

Regards.
Typo?
As far as I can see, there is a typo here.
ItemName="ItemsFromFile"

should be

PropertyName="ItemsFromFile"

- That's the only way I can get it working anyway :)