sdk icon indicating copy to clipboard operation
sdk copied to clipboard

SDK ignores output type when targeting WinForms

Open davkean opened this issue 5 years ago • 8 comments

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.

davkean avatar Jan 29 '21 03:01 davkean

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.

ghost avatar Jan 29 '21 03:01 ghost

@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 avatar Mar 03 '21 21:03 joeloff

@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 avatar Mar 03 '21 21:03 davkean

@davkean you're thinking property pages in VS where the user can just toggle between the "Windows Application" and "Console Application"?

joeloff avatar Mar 03 '21 21:03 joeloff

Yes. I've been able to toggle WinForms apps between Console -> WinApp for coming on ~20 years, except for .NET Core.

davkean avatar Mar 03 '21 21:03 davkean

@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.

marcpopMSFT avatar Mar 03 '21 22:03 marcpopMSFT

@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

ChahatKumar avatar May 17 '21 18:05 ChahatKumar

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.

github-actions[bot] avatar Apr 23 '26 05:04 github-actions[bot]