This project is read-only.

FileSystem.File.WriteLines - empty text file?

Mar 8, 2012 at 8:56 PM

Is it possible to create an empty text file using File.WriteLines? It seems to be insisting that Lines cannot be empty but I do in fact want an empty, 0 byte file created. I tried passing a space or using an Item group with a blank line but "Lines is Required" error remains. Please advise if there is a way to do this with this task or maybe another extension pack task or built in task? Thanks

<MSBuild.ExtensionPack.FileSystem.File TaskAction="WriteLines" Files="$(BuildArtifacts)licenses.licx" Lines=""/>
Mar 9, 2012 at 12:14 PM

You'll need to compile the latest code and then use

        <FilesToCreate Include="d:\a\File1-100.txt"/>
        <FilesToCreate Include="d:\a\File2-100.txt"/>
        <FilesToCreate Include="d:\a\File3-5000000.txt">
        <FilesToCreate Include="d:\a\File4-100.txt"/>
    <Target Name="Default">
        <!-- Create some files. Defaults the size to 1000 bytes, but one file overrides this using metadata -->
        <MSBuild.ExtensionPack.FileSystem.File TaskAction="Create" Files="@(FilesToCreate)" Size="1000"/>