question

GuruGurra-5133 avatar image
1 Vote"
GuruGurra-5133 asked MagnusInghardt-5435 published

Project output type forced to "Windows Application"

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???



vs-general
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @GuruGurra-5133 , thank you for taking time to post this issue in Microsoft Q&A forum. Did you update other applications, tools or extensions except Visual Studio? Did you develop this application with other team members(maybe)? Please try these steps to troubleshoot:

1). Please close every VS instances and go to this path: C:\Users\[username]\AppData\Local\Microsoft\VisualStudio\16.0_XXXX and rename(or delete) every folders named “ComponentModelCache”. Then go to your solution(or project) folder and rename or delete the bin, obj and the hidden .vs folders, after that open your project and rebuild it.

2). Please disable any third-party extensions temporarily from Extensions > Manage Extensions > Installed > Disable and test again.

3). If you try to create a new simple project and test to publish it, will this issue appear again?

0 Votes 0 ·
GuruGurra-5133 avatar image
0 Votes"
GuruGurra-5133 answered

Thanks for the suggestions @TianyuSun-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.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

GuruGurra-5133 avatar image
3 Votes"
GuruGurra-5133 answered MagnusInghardt-5435 published

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.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

This solution works for me. It either happened because of upgrading to v16.8.2 or when I added an Azure Functions project to my solution - can't say for sure.

0 Votes 0 ·

Worked for me aswell.
It happend when i upgraded the project from .Net framework to .Net 5 using the upgrade assistant.

0 Votes 0 ·