Project output type forced to "Windows Application"

GuruGurra 21 Reputation points
2020-11-15T22:52:21.377+00:00

I have a .Net Core 3.1 C# project that is and has always been a Console Application, but all of a sudden Visual Studio claims that it is a Windows Application and I cannot change it (or rather, I can change it but Visual Studio changes it back to Windows Application").

I've been working on this project for a long time and have had no problems, but suddenly I cannot publish the project any more.

Some more details:

  • The project have both Windows and Mac as targets and I have two publish profiles; one for Windows (win10-x64) and one for Mac (osx.10.12-x64).
  • As mentioned above the output type is/should be Console Application.
  • I've had no problems publishing with both profiles before.
  • I might have done a Visual Studio update but I can't really remember. (Using Community 2019, version 16.8.1 now)

When I now try to publish for PC, I get the error message "There was no runtime pack for Microsoft.WindowsDesktop.App.WindowsForms available for the specified RuntimeIdentifier 'osx.10.15-x64'.", something that is extremely odd since it isn't a WindowsDesktop application, it isn't using WindowsForms and it shouldn't bother about osx versions when I publish to PC (and in addition - I have specified osx.10.12-x64, not osx.10.15-x64 for Mac).

Further investigation shows that the RuntimeIdentifiers tag in the project file somehow is changed to now reference osx.10.15-x64 and not osx.10.12-x64 that I did specify. And in addition there is the problem that I cannot change output type to Console Application. If I do that change, close the properties window and open it again it is back to Windows Application.

I can build the project, but not publish it. What the f.. is going on???

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,620 questions
{count} vote

2 answers

Sort by: Most helpful
  1. GuruGurra 21 Reputation points
    2020-11-16T10:52:02.123+00:00

    Problem solved.

    I found the following line in the project file:

    <UseWindowsForms>true</UseWindowsForms>

    I have no idea how/when that line was added, but when I removed it everything went back to normal - the project became a Console Application and I could publish it.

    3 people found this answer helpful.

  2. GuruGurra 21 Reputation points
    2020-11-16T10:43:14.657+00:00

    Thanks for the suggestions @Tianyu Sun-MSFT .

    • I know I investigated the list of installed components when I updated VS but my intention wasn't to change anything. Is there a log anywhere from the last update that can show if I unintentionally made some changes?
    • No other team members are involved.
    • I have tried to remove all the folders you mention and rebuild the project - no change.
    • All extensions are disabled - no change.
    • I created a new project. That project publish just fine and keeps the "Console Application" type.
    • I published my project 5 days ago without any problems.
    0 comments No comments