TFS 2013 Build - Adding log in Activity Log

1k Views Asked by At

We are using TFS build in 2013 to automate build & deploy process. For this we have also added some powershell scripts that perform some tasks like copying of binaries to a central location etc.

To add logs during the process we use "Write-Host" method. It logs message in the detailed log but I would like to add them in the Activity logs so that it can be shown in the IDE itself during the build process.

How can we achieve this?

2

There are 2 best solutions below

2
On

There is another parameter on that activity for at what verbosity it shows. If you change it from the default of "high" to "Normal" it should show in the main log without having to change the build verbosity...

0
On

Instead of Write-Host, you should use Write-Output or Write-Error to write your logging messages.

Write-Host writes to whatever is hosting PowerShell, which could be the PowerShell command shell, the PowerShell ISE, or even a custom PowerShell host written in .NET. It is up to the host as to whether or not to actually display what is passed to it. Write-Output, on the other hand, will output to the stdout stream. Write-Error will write to stderr.

There is also Write-Verbose, which will log to the verbose output stream. However, in my experience with TFS builds, output from Write-Verbose is not captured.

Here is a good background explanation if you want more.