Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to build standalone single file executables #1278

Closed
strich opened this issue Feb 22, 2018 · 4 comments
Closed

Ability to build standalone single file executables #1278

strich opened this issue Feb 22, 2018 · 4 comments

Comments

@strich
Copy link

strich commented Feb 22, 2018

Issue Title

Recently I've been looking into building a small application to solve a problem and I immediately reached for .NET Core. I needed to be able to run the app on Win, Linux and Mac.

General

A wrote a small application with a few dependencies. Primarily the EF.Core.SQLite package as I needed to read some information from a local SQLite file. Nothing beyond that. I used the internally available HTTP Client to do some HTTP POST/GET stuff.

Unfortunately I hadn't done my research as I noticed that by default .NET Core Console apps build to an executable dll. Not quite what I had in mind - From a developer UX perspective is this really correct? Surely the common usecase for Console apps would still be an executable that a user would still want to treat as an exe and not as something run from a console with dotnet MyApp.dll.

Anywho I soon realised I can use dotnet publish to compile an executable and furthermore do so as a standalone by copying the required dlls into the same directory so it can run without any .NET installation on the machine. However I was fairly surprised that there were a total of 240 or so separate DLL files. For my purposes I'm not sure I could distribute my application like this - My users would bulk as having to integrate such a large sum of files.

For my purposes I really need a single executable file, from a user UX perspective. The file itself can be quite large - The DLLs above weighed in at 60MB, which, is pretty damn large for such a small app, but again not necessarily a pain for me.

I suppose my key point here is: Is there a concerted effort to be able to use .NET Core to create standalone single file (Or at least <5 file) applications?

@Petermarcu
Copy link
Member

A few comments/questions:

  1. Are you willing to install the runtime as a pre-requisite or do you want to ship the runtime with the application? There is a feature that is being designed to enable apps that depend on a runtime still having an exe. This world would allow your app to be much smaller but would require that .NET Core Runtime that you depend on be installed on the target machine.

  2. We have a preview of a linker that will shake out code that is not used and usually makes the app smaller but doesn't change the number of dll's. Check out https://github.com/dotnet/core/blob/master/samples/linker-instructions.md

  3. The next step after the linker will be something that is being called "bundling" which is exactly what you talked about. The ability to have a single executable artifact. There isn't a clear timeline/roadmap on that one but I know there are people looking into it.

  4. You mentioned users not wanting to integrate such large numbers of files. Is the option of putting up a zip file that you just tell people to extract an option? If all the files were in a sub folder and when they opened your app it was just an exe (maybe also a config) and then a sub folder with "dependencies", would that help?

@strich
Copy link
Author

strich commented Feb 23, 2018

In this particular instance the application is a sort of middleware that would be part of a larger application by the end user (A developer). They may or may not be using .NET at all. So it is pretty important that I don't force them to have to add entire framework installers to deploy alongside it just to support this middleware.

The linker looks promising and was something I had stumbled upon previously, but I suppose what I'm really looking for is the bundling feature. Without it I don't think this middleware app will survive without a lot of heat from the user.

I daresay my application as middleware is not one of the most common usecases, but I do think it is important that bundling is made available soon as the ability to quickly write and deploy a single file solution is powerful.

@Petermarcu
Copy link
Member

Agreed that this would be a useful feature. @sbomer @jeffschwMSFT as FYI. I think this may be tracked elsewhere but I'll leave this issue open for now unless there is a better one to point to.

@Petermarcu
Copy link
Member

Issue moved to dotnet/coreclr #17015 via ZenHub

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants