Self Contained Single File App With .NET Core

In .NET Core there is now an easy way to publish your app as a single exe. No extra dependencies, no installers. But with some caveats that you need to be aware of.

The good

After creating a basic console app using dotnet new console we have a starting point. To publish it then as single exe you need to run

dotnet publish -r win10-x64 /p:PublishSingleFile=true

Simple as that. That packs all this

All files

into just this

Single file

The (not so) bad

As mentioned at the start, there are few things that you should know:

Not really single exe

Currently it’s basically just a smart zip file, so on first startup it takes a long time (since it needs to extract the zip), even more so when your app is not just a hello world.

Disk usage

Related to the previous one is another issue - each build of your app has different internal ID. That ID is then used as part of the extraction destination path. Currently on Windows 10 it’s ... \AppData\Local\Temp\.net\{app_name}\{build_id}

Disk usage


The special extraction path might potentially cause you problems if you are expecting things to be at some specific locations related to the exe. You can see this in action if you modify the program like this:

static void Main(string[] args)

which prints out


The future

Worth checking out are the plans and vision for this feature described at here


comments powered by Disqus