md DotNetCore2ConsoleExe
sl DotNetCore2ConsoleExe
dotnet new console
gc .\DotNetCore2ConsoleExe.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
</Project>
dotnet build
Microsoft (R) Build Engine version 15.3.117.23532
Copyright (C) Microsoft Corporation. All rights reserved.
DotNetCore2ConsoleExe -> C:\Source\Repos\Rulers\DotNetCore2ConsoleExe\bin\Debug\netcoreapp2.0\DotNetCore2ConsoleExe.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:03.43
Output should be executable (DotNetCore2ConsoleExe.exe)
Output was a DLL (DotNetCore2ConsoleExe.dll)
dotnet --info
output:
.NET Command Line Tools (2.0.0-preview1-005977)
Product Information:
Version: 2.0.0-preview1-005977
Commit SHA-1 hash: 414cab8a0b
Runtime Environment:
OS Name: Windows
OS Version: 10.0.14393
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.0.0-preview1-005977\
Microsoft .NET Core Shared Framework Host
Version : 2.0.0-preview1-002111-00
Build : 1ff021936263d492539399688f46fd3827169983
BTW, I read this: https://github.com/dotnet/cli/issues/6237
And, yeah, considering you have millions of .NET Framework developers new to .NET Core who know all about Windows .exe files and not that much about macOS and *nix, calling it an Exe when what you mean is "library that has a standard Main" is misleading to say the least. Call it "app" or something.
@CodeCharm How did you fix this issue for you? I am still hopelessly trying to generate an .exe and all I get is a .dll.
@zunder It's not really "fixed." Read that thread: dotnet/sdk#8065 - it's apparently a "by design" feature, although I personally think the design ought to change. After all, every OS has the concept of an executable binary. However, the thing I needed most was to get the exit code from my static int Main(args[])
, and I was able to do that, even by calling dotnet.exe
and having it run my (ahem) "executable" DLL.
Apparently (not that I've tried this) -- the way to actually get the .exe file (for Windows, for example) is to publish the project and create a "self-contained deployment" (https://docs.microsoft.com/en-us/dotnet/core/deploying/index#self-contained-deployments-scd)
And you have to love what happens if you try to run it.
C:\Dev\software\Bin\Debug\netcoreapp2.1>software.dll
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
C:\Dev\software\Bin\Debug\netcoreapp2.1>dotnet software.dll
Hello, World!
Most helpful comment
@zunder It's not really "fixed." Read that thread: dotnet/sdk#8065 - it's apparently a "by design" feature, although I personally think the design ought to change. After all, every OS has the concept of an executable binary. However, the thing I needed most was to get the exit code from my
static int Main(args[])
, and I was able to do that, even by callingdotnet.exe
and having it run my (ahem) "executable" DLL.Apparently (not that I've tried this) -- the way to actually get the .exe file (for Windows, for example) is to publish the project and create a "self-contained deployment" (https://docs.microsoft.com/en-us/dotnet/core/deploying/index#self-contained-deployments-scd)