Why Did .NET Core Build A .dll and not an .exe?

June 16 2016

Started playing with .NET Core and, typical developer, didn’t read any docs first. Installed the tools, created a new project and typed Console.WriteLine(“Hello world.”).  And what did I get when I compiled? A .dll?  Weird. There was a public static void main(). What did I do wrong?

Well, I went and read some docs, in particular, this one: https://dotnet.github.io/docs/getting-started/cli-console-app-tutorial.html 

and I learned that you have to include a runtimes node to target execution environments, so I changed my project.json to include the runtime node in the project.json file like this:

{ "version": "1.0.0-*", "buildOptions": { "emitEntryPoint": true }, "dependencies": { "Microsoft.NETCore.App": { "version": "1.0.0-rc2-3002702" } }, "frameworks": { "netcoreapp1.0": { "imports": "dnxcore50" } }, "runtimes": { "win10-x64": {}, "osx.10.11-x64": {} } }

Well, my app didn’t compile! Why? Because I was running on Windows Server 2012, which requires the win8-x64 runtime. I added that so my runtime node looked like:

"runtimes": { "win8-x64": {}, "win10-x64": {}, "osx.10.11-x64": {} }

And, walla, my code compiled and a directory was generated with a .exe.  Hello world!

Add comment

  • Comment
  • Preview