MSBuild's PowerShell call breaks long lines of text

I have an MSBuild script that calls a PowerShell script. The PS script output contains several long lines, and some of them (but not all) are divided into several lines, for example.

wait-untilOpCompleted : Cannot bind argument to parameter 'operationId' because
   it is null.

How can i stop this? I just need one long line, for example:

wait-untilOpCompleted : Cannot bind argument to parameter 'operationId' because it is null.
+3
source share
2 answers

The easiest way to prevent PowerShell line breaks based on console width is to override the Out-Defaultdefault implementation at the top of your script like this:

filter Out-Default { 
   $input | Out-String -Width 500 -Stream | 
            Microsoft.PowerShell.Utility\out-default 
}
+3
source

. , , , , - . :

# Update output buffer size to prevent clipping in Visual Studio output window.
if( $Host -and $Host.UI -and $Host.UI.RawUI ) {
  $rawUI = $Host.UI.RawUI
  $oldSize = $rawUI.BufferSize
  $typeName = $oldSize.GetType( ).FullName
  $newSize = New-Object $typeName (500, $oldSize.Height)
  $rawUI.BufferSize = $newSize
}

500 RawUI (, , , script , , ).

, RawUI ( ), :

$Host.UI.RawUI.BufferSize = New-Object Management.Automation.Host.Size (500, 25)
0

Source: https://habr.com/ru/post/1795351/


All Articles