Sdk: dotnet run buffers piped output from child process when using Console.Write()

Created on 22 Mar 2016  路  4Comments  路  Source: dotnet/sdk

Piping output was mentioned in dotnet/sdk#4362 and marked as complete but the current implementation has issues. I wonder why we're piping at all and not just letting the child process take over the launching process' output.

Steps to reproduce

Create a console app with the following and run it using dotnet run:

``` c#
using System;

namespace ConsolePipeBroken
{
public class Program
{
public static void Main(string[] args)
{
Console.Write("Type: ");

        ConsoleKeyInfo inputChar;
        while (inputChar.Key != ConsoleKey.Enter)
        {
            inputChar = Console.ReadKey();
            Console.Write(inputChar.KeyChar.ToString());
        }

        Console.WriteLine();
        Console.WriteLine("Enter key pressed, exiting");
    }
}

}
```

Expected behavior

You see "Type: " printed then as you type chars they appear in the console window. When you hit 'Enter' the exit line is printed and the process exits.

Actual behavior

You see nothing printed when the app runs, you start typing chars and nothing appears until you hit 'Enter' at which point the entire console output is printed and the process exits.

Environment data

dotnet --version output:
.NET Command Line Tools (1.0.0-beta-001898)

Product Information:
Version: 1.0.0-beta-001898
Commit Sha: 43ac2b45f4

Runtime Environment:
OS Name: Windows
OS Version: 10.0.10586
OS Platform: Windows
Runtime Id: win10-x64

Most helpful comment

@piotrpMSFT @blackdwarf can we please get this looked at for the next tools preview. This is making it impossible to use dotnet run when writing interactive console applications, like project tools.

I suggest we revisit the entire idea of piping at all and just let the app write direct to the console.

All 4 comments

I'm seeing this too. This makes it difficult to test interactive console apps with dotnet run and impossible to make a tool extension.

@piotrpMSFT @blackdwarf can we please get this looked at for the next tools preview. This is making it impossible to use dotnet run when writing interactive console applications, like project tools.

I suggest we revisit the entire idea of piping at all and just let the app write direct to the console.

This seems like it was fixed in the latest (Preview 3) bits, so I'm going to close. The repro specified above by @DamianEdwards works now as it should. If still repros, please reopen.

Was this page helpful?
0 / 5 - 0 ratings