Search code examples
wpfvisual-studio.net-core

Visual Studio 16.8 just disabled having a console in a WPF Core 3.1 app?


Using Visual Studio, some time ago I created a .NET Core 3.1 with WPF app. Then, in the project properties, I changed the 'Output type' to 'Console Application' so that I would have a nifty console to print stuff out to. That has been working fine for quite a while. But I just updated VS from 16.7.6 to 16.8.1 and now the app won't open a console window, and when I open the project properties the 'Output type' says 'Windows Application', and when I change it again to 'Console Application', the next time I open project properties it again says 'Windows Application' (even though the csproj file has a OutputType of 'Exe' in it, which means its a console app).

Am I doing something wrong or has Microsoft suddenly decided to disable console windows with WPF Core (3.1) apps, even though they let you change the output type to 'console application' at least while the project properties is open, and they did this without telling anybody (at least, I haven't found a statement to that effect)?


Solution

  • This problem should apply only to .NET 5 but maybe it's the case of .NET Core 3.1 with the new Visual Studio version too.

    In my case, I converted the .NET Core 3.1 project to .NET 5. I had to change the 'Output type' to 'Windows Application'. Then edit the csproj file and add the following line after <OutputType>WinExe</OutputType>:

    <DisableWinExeOutputInference>true</DisableWinExeOutputInference>
    

    See this MS doc page.

    Try it with your .NET Core 3.1 project.