.NET Core App Confusion – Missing exe

Build/Deployment Confusion

After creating a quick console app using .NET Core I noticed something unfamiliar in the bin/publish directory. With the default project setup there is no exe, it is missing:

default publish output

Why!? – Framework-Dependent Deployment

By default the new .NET Core application is setup to be built and deployed using the framework-dependent deployment. This means we are relying on .NET Core to be installed on the machine(s) we are going to run the app on.

What does this is line # 9 of project.json:

{
  "version": "1.0.0-*",
  "buildOptions": {
    "emitEntryPoint": true
  },
  "dependencies": {
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.1"
    }
  },
  "frameworks": {
    "netcoreapp1.0": {
      "imports": "dnxcore50"
    }
  }
}

To run the console app just drop to the command line and enter the following after changing to the deployed directory:

dotnet ConsoleApp1.dll

Self-contained deployment

The self-contained deployment will bring back the EXE. The “self-contained” means that the actual .NET Core runtime and libraries are compiled with the application, it’s all portable. To do this take out the line that contains “type”: “platform”, also add the “runtimes” selection and include runtimes that should be compiled, in this case we’re using windows-10 64 bit:

{
  "version": "1.0.0-*",
  "buildOptions": {
    "emitEntryPoint": true
  },
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.1"
    }
  },
  "frameworks": {
    "netcoreapp1.0": {
    }
  },
  "runtimes": {
    "win10-x64": {}
  }
}

Now after publishing you can see the output not only contains our “missing” exe but also the entire runtime:

self-contained-publish-output

For more details Microsoft just published a detailed guide on this subject last week: https://docs.microsoft.com/en-us/dotnet/articles/core/deploying/index

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s