Project Output Type forced to Windows Application from Console Application - Visual Studio Upgrade 16.8.1

Bartosz Wojtowicz 6 Reputation points
2020-11-19T15:09:08.937+00:00

I have a similar problem to this one that started occurring after I installed VS 16.8.1 yesterday. My project is a WPF project for which I want to open a console as well. So, in the project properties Output Type was set to Console Application and all worked fine. Since the update that Output type is reset to Windows application with every build and when I run the project the console is not launched and app crashes because it can't access the Console properties (i.e. Console.BufferWidth)

This is my projects content. It doesn't specify anywhere it is a console app, maybe that is the problem. The Output type from the Project Properties window is not persisted.

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

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net461</TargetFramework>
<UseWPF>true</UseWPF>
<StartupObject>Viewer.Program</StartupObject>
</PropertyGroup>

I cannot remove <UseWPF>true</UseWPF> flag because then the project doesn't compile as I use WPF components.
Can you please advice how to get it working again?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,595 questions
Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
938 questions
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
35,929 questions
0 comments No comments
{count} vote

3 answers

Sort by: Most helpful
  1. Dylan Zhu-MSFT 6,406 Reputation points
    2020-11-20T05:38:13.88+00:00

    Hi BartoszWojtowicz-7700,

    I'm afraid that you can't do that. The <UseWPF> means that your project is a wpf application instead of a console application, so you could not get and set the properties of console. Or we suggest you could recreate a console for your project.

    Best Regards, Dylan

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our * *documentation* to enable e-mail notifications if you want to receive the related email notification for this thread.**


  2. rbqm 1 Reputation point
    2020-11-20T08:29:53.2+00:00

    What I did to solve this problem is change the Sdk to "Microsoft.NET.Sdk", remove the UseWpf and UseWindowsForms elements, and manually add back the required WPF assembly references.


  3. LauXjpn 1 Reputation point
    2021-01-19T17:16:24.797+00:00

    This breaking change has been documented as OutputType set to WinExe for WPF and WinForms apps:

    However, if you want to revert to the old behavior, set the DisableWinExeOutputInference property to true in your project file.

    <DisableWinExeOutputInference>true</DisableWinExeOutputInference>

    0 comments No comments