I needed to use one of the primitive task, WriteLine, that is available for TFS Build Process Definition.
My aim was to create a file with version information gets written a file in output directory of the build.
WriteLine task has following two properties that are needed to be set:
WriteLine.Text = "Text to be written by this task"
WriteLine.TextWriter = "TextWriter object that will write the text"
It is pretty simple task to use. However, I could not get anything written to the file. I could see file being created. I set following values to these properties:
WriteLine.Text = "Sample text to be written to file"
WriteLine.TextWriter = New StreamWriter(outputDirectory + "\sampletextfile.txt")
As simple as it appears, it did not work for me. However after I set StreamWriter.AutoFlush property to true and Append = false, it worked just fine.
It could be that WriteLine task handles writing to the stream differently.
I set following value to WriteLine.TextWriter property and it worked FINE.
New StreamWriter(outputDirectory + "\sampletextfile.txt", False) With {.AutoFlush = True}