Skip to content

Console output no longer working dotnet run and UseWindowsForms #41922

@sipsorcery

Description

@sipsorcery

Description

For console applications that need to display a Windows Form executing the project with dotnet run displayed Console.Write* output in the same manner as a standard console application.

With .NET SDK (5.0.100-preview.8.20417.9) console output is no longer displayed.

If the program is built with Visual Studio and then run from directly from the .exe, with the Visual Studio debugger or with dotnet run --no-build then console output works properly.

If the program is build and run with dotnet run console output does not appear.

Configuration

.NET SDK (5.0.100-preview.8.20417.9)
Microsoft Windows 10 Pro 10.0.19041 Build 19041
x64

Other information

Minimal project and program file to replicate:

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <UseWindowsForms>true</UseWindowsForms>
  </PropertyGroup>

</Project>
using System;

class Program
{
    [STAThread]
    static void Main(string[] args)
    {
        Console.WriteLine("Hello World!");
    }
}
  • Build and execute with dotnet run will not display anything on the console.
  • Rebuild with Visual Studio and execute with dotnet run --no-build will display console output.
  • Build and execute again with dotnet run will not display anything on the console.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions