SDK ignores output type when targeting WinForms
For testing purposes, I often switch from a WinExe -> Exe so that I can see Console input. Unlike .NET Framework, I can't do that in SDK based projects, because its ignoring my OutputType:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
</Project>
Expected: For my app to have Console window Actual: My app does not have a Console window.
It is understandable that OutputType defaults to WinExe if its not specified, but the project should always win out. This also breaks Properties pages that don't expect this at all.
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
@davkean The SDK tries to infer the output type, but you can turn that off, e.g.
<PropertyGroup>
<DisableWinExeOutputInference>true</DisableWinExeOutputInference>
<OutputType>Exe</OutputType>
</PropertyGroup>
@joeloff The UI isn't aware of this, and the design that we've had with past properties is that the project file always wins.
@davkean you're thinking property pages in VS where the user can just toggle between the "Windows Application" and "Console Application"?
Yes. I've been able to toggle WinForms apps between Console -> WinApp for coming on ~20 years, except for .NET Core.
@dsplaisted please raise this in the partner meeting as we should consider what changes we want to make to the outputtype inference based on feedback we've gotten.
@davkean hi , i wanted to know how you exactly references the Windows.Forms dll in the .NET console app
When i try adding a COM reference , it gives error . Have you referenced using Object Browser ( under that in .net frameworks i found them )
apologies if this is out of topic here
Due to lack of recent activity, this issue has been labeled as 'Stale'. It will be closed if no further activity occurs within 14 more days. Any new comment will remove the label.