-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Spinning 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.)