2

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?

Lalit
  • 352
  • 8
  • 22

2 Answers2

1

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.

JamesQMurphy
  • 4,214
  • 1
  • 36
  • 41
0

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...

  • 1
    We are using the default build template TfvcTemplate.12.xaml. We are running a Powershell script via the Post-build script. That script uses all the types of output for logging (write-host, output, verbose, warning & debug) but nothing comes out on the log tab during the build. Only showing under the diagnostic tab after the build has completed. Have we missed something? – SmudgerDan Jul 31 '15 at 08:50
  • You can either explicitly Write-Verbose, or increase the verbosity level in PowerShell. Default is normal which will not get emitted. – MrHinsh - Martin Hinshelwood Aug 03 '15 at 08:05