.NET Core shouldn't use OutputType=Exe/WinExe when it means something else
See original GitHub issueSpinning off from #1906, .NET Core, by design, currently doesn’t build AnyCPU exes. However, it uses MSBuild syntax that implies otherwise, such as:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net47</TargetFramework>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
</Project>
In .NET Framework, it made sense to have an OutputType of Library (DLL), Exe (console EXE) or WinExe (non-console EXE), as that directly matched the type of Windows PE produced.
In .NET Core, the output type is always a DLL on Windows (if I understand correctly), which may or may not have code designed to work as an entry point. To eliminate the confusion here, distinct MSBuild syntax could help quite a bit. For example, consider:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<EntryPointType>Console</EntryPointType>
<TargetFramework>net47</TargetFramework>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
</Project>
Where EntryPointType is one of: None, Console, NonConsole Or maybe: HasEntryPoint: true/false IsConsoleApplication: true/false
I think this would have led to less surprise in issues like dotnet/cli#6237. (That issue is still useful as a feature request for building an actual .exe on Windows - this one is about the MSBuild contract when producing a .NET Core application with an entry point.)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:11
- Comments:11 (4 by maintainers)
Top GitHub Comments
K.I.S.S!
Developers has been using Microsoft tools to produce code for windows for decades, and there’s an established standard way how stuff work. When things don’t work or behave as the always have, people (including developers) get confused, problems arise and time is wasted trying to figure out what is going on. So, for the tens of millions of developers out there that has been using VS/MsBuild for decades, they get really confused when see a project with the output type set to “Console Application” and the project file contain
<OutputType>Exe</OutputType>
, and they then end up with a DLL.Yes, or MS could produce a project file with a helpful comment. Communication: it’s necessary™.
P.S. why not use a .exe file extension?