0

使用此命令结果分为两行,首先修剪 59 个字符,第二个 - 所有其他字符

$command ='nuget.exe list "Json.NET" -source "https://www.nuget.org/api/v2/"'
(Invoke-Expression "$command") | out-file C:\test.txt

它看起来像一些奇怪的自动换行,并且只出现在 Windows PowerShell ISE 中(Powershell.exe 工作正常)

增加缓冲区大小对我不起作用

$host.UI.RawUI.BufferSize = new-object System.Management.Automation.Host.Size(512,50)

这行得通

start-process $nugetExe $command -wait -WindowStyle Hidden -RedirectStandardOutput C:\test.txt -RedirectStandardError C:\error.txt

但它仅在排除“RedirectStandardError”时才有效,如果它存在 - 包装仍然在原地如果我使用相同的问题

$process.StartInfo.RedirectStandardError = $true;  
4

1 回答 1

0

尝试使用例如-Width参数Out-File

nuget.exe list "Json.NET" -source "https://www.nuget.org/api/v2/" | 
    Out-File C:\test.txt -Width 256
于 2014-01-09T05:02:30.810 回答