Tag Archives: Gotchas

TFS Build Process Definition WriteLine Task

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}

Login failed for a member of Domain Admin AD Group on SQL Server

I ran into a situation where on our SQL Server, we have [Domain Admin] AD Group added for Login and has sysadmin role granted for the server.

My username is part of [Domain Admin] AD group. But still when I log on to SQL Server using SQL Server Management Studio, it gives me Login Failed message.

The reason it is not working is because, I was NOT running SQL Server Management Studio as Administrator.

Once I started SQL Server Management Studio as Administrator, it worked.

Powershell – Executing generated command string

I ran into a situation where within my powershell script, I had to create a string with a command and all possible arguments to it.

This means I had a string variable with something like this:


$cmd = '"C:\some path\someprogram.exe" -p Argument="Value" -p ArgumentTwo="ValueTwo"'

Now many posts on the internet showed that you can execute a command from string variable by just putting & in the from which is an expression execution directive.
So, to execute, I wrote

& $cmd;

But that didn’t work. Since my string had long paths and spaces in it. To properly execute I tried following and it worked nicely:


Invoke-Expression -Command "&$cmd";

Hope this helps.

U