Search code examples
powershelltfsbuild

TFS Custom Build Task, Powershell script shows additional blank lines in log


When running a custom build task that includes a powershell script, there will be additional blank lines in my log. How it looks like: two additional blank lines between "Write-Host"'s.

My Powershell Skript:

Write-Host "# #############Run SQL Script############# #"
Write-Host "Instance of the Database Server: $Database_ServerInstance"
Write-Host "FilePath of the SQLScript: $Script_FilePath"

How do I get rid of the additional blank lines?


Solution

  • When you write

    Write-host “hello”
    

    You actually get :

    'hello' | Out-Default | Out-Host
    

    PowerShell will apply the default formatting (which can be altered by configuration files on the host) to Out-default and the again to out-host (display in our case) . Even worst, the formatting rules are different among versions and for desktop and server PowerShell.

    try with write-output to see if you get different formatting.