TFS 自定义生成任务,Powershell 脚本在日志中显示额外的空行

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

当 运行 包含 powershell 脚本的自定义构建任务时,我的日志中会有额外的空行。 它看起来如何:

我的 Powershell 脚本:

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

如何去掉额外的空白行?

写的时候

Write-host “hello”

你实际得到:

'hello' | Out-Default | Out-Host

PowerShell 会将默认格式(可以通过主机上的配置文件更改)应用到 Out-default,然后再次应用到 out-host(在我们的例子中显示)。 更糟糕的是,不同版本以及桌面和服务器 PowerShell 的格式设置规则不同。

尝试使用 write-output 看看您是否得到不同的格式。