Skip to content

Commit c7b3571

Browse files
committed
Fix error when info stream is redirected to file.
1 parent 4d85e61 commit c7b3571

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

PSql.Deploy/Commands/AsyncPSCmdlet.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,17 @@ public void WriteHost(
234234
ConsoleColor? foregroundColor = null,
235235
ConsoleColor? backgroundColor = null)
236236
{
237-
// This will invoke WriteInformation below
238-
((PSCmdlet) this).WriteHost(text!, newLine, foregroundColor, backgroundColor);
237+
static void WriteHost((
238+
PSCmdlet cmdlet,
239+
string? text,
240+
bool newLine,
241+
ConsoleColor? foregroundColor,
242+
ConsoleColor? backgroundColor) x)
243+
=> x.cmdlet.WriteHost(x.text, x.newLine, x.foregroundColor, x.backgroundColor);
244+
245+
Dispatcher.Invoke(
246+
WriteHost, ((PSCmdlet) this, text, newLine, foregroundColor, backgroundColor)
247+
);
239248
}
240249

241250
/// <inheritdoc/>

0 commit comments

Comments
 (0)