Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
WriteLinesToFile Task

WriteLinesToFile Task

Writes the paths of the specified items to the specified text file.

The following table describes the parameters of the WriteLinestoFile task.




Required ITaskItem parameter.

Specifies the file to write the items to.


Optional ITaskItem[] parameter.

Specifies the items to write to the file.


Optional Boolean parameter.

If true, the task overwrites any existing content in the file.


Optional String parameter.

Selects the character encoding, for example, "Unicode". See also Encoding.

If Overwrite is true, creates a new file, write the contents to the file, and then closes the file. If the target file already exists, it is overwritten. If Overwrite is false, appends the contents to file, creating the target file if it does not already exist.

In addition to the parameters listed above, this task inherits parameters from the TaskExtension class, which itself inherits from the Task class. For a list of these additional parameters and their descriptions, see TaskExtension Base Class.

The following example uses the WriteLinesToFile task to write the paths of the items in the MyItems item collection to the file specified by the MyTextFile item collection.

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

        <MyTextFile Include="Items.txt"/>
        <MyItems Include="*.cs"/>

    <Target Name="WriteToFile">

© 2015 Microsoft