Closed
Description
The goal of this effort is enable .Net-Core apps to be published and distributed as a single executable.
Goals
The .Net 5.0 single file solution should be:
- Widely compatible: Apps containing IL assemblies, ready-to-run assemblies, composite assemblies, native binaries, configuration files, etc. can be packaged into one executable.
- Can run managed components of the app directly from bundle, without need for extraction to disk.
- Usable with debuggers and tools.
User Experience
Here's the overall experience for publishing a HelloWorld single-file app in .net 5:
-
Framework-dependent
- Publish command:
dotnet publish -r win-x64 --self-contained=false /p:PublishSingleFile=true
- Published files:
HelloWorld.exe
,HelloWorld.pdb
- Publish command:
-
Self-contained (Linux)
- Publish command:
dotnet publish -r linux-x64 /p:PublishSingleFile=true
- Published files:
HelloWorld
,HelloWorld.pdb
- Publish command:
-
Self-contained (Windows):
- Publish command:
dotnet publish -r win-x64 /p:PublishSingleFile=true
- Published files:
HelloWorld.exe
,HelloWorld.pdb
,coreclr.dll
,clrjit.dll
,clrcompression.dll
,mscordaccore.dll
- Publish command:
-
Self-contained (Windows) with bundled native components:
- Publish command:
dotnet publish -r win-x64 /p:PublishSingleFile=true /p:IncludeNativeLibrariesInSingleFile=true
- Published files:
HelloWorld.exe
,HelloWorld.pdb
- Publish command:
Design Document
A detailed discussion of the goals, non-goals, related-work, options, design decisions, and implementation details of supporting single-file apps is available in this design document
Tracking Progress
- Initial proposal and poll for customer response:
- Poll on GitHub: Support single-file distribution #11201
- Enterprise customer poll
- Propose staged implementation of the feature.
- Support single-file apps through extraction (.net core 3)
- Self-Extractor Design.
- SDK support for publishing apps as a single-file. Publish to Single-File sdk#3132
- AppHost support for extracting contents of a single-file bundle at startup. AppHost: Support bundles (stage 1) core-setup#5742
- Support single-file apps running from bundle (.net 5)
- HostModel library
- Implement bundle format version 2. AppHost: Support bundles (stage 1) core-setup#5742
- SDK
- Implement support for publishing a few files when necessary for
PublishSingleFile
. Single-File: Update Bundler Invocation. sdk#11586 - Implement optional settings for single-file publishing. Use SingleFileHost sdk#11797
- Use SingleFileHost when publishing self-contained single-file apps. Use SingleFileHost for self-contained single-file apps sdk#11567 Use SingleFileHost sdk#11797
- Trim the set of native dependencies used for single-file publish. Produce DropFromSingleFile annotations in RuntimeList.xml #36578 Use SingleFileHost sdk#11797
- Implement support for publishing a few files when necessary for
- Host
- Move bundle-processing from the host to the framework . Single-File: Process bundles in the framework #34274
- Process
deps.json
andruntimeconfig.json
files directly from bundle. Single-File: Process bundles in the framework #34274 - Implement a callback for the runtime to probe the contents of the bundle. Single-File: Pass BUNDLE_PROBE property to the runtime #34845
- Host Builds
- Windows: Implement
SingleFileHost
withAppHost
,HostFxr
, andHostPolicy
statically linked. Single-File: Implement statically linked apphost #32823 Build an apphost with hostfxr and hostpolicy linked in #36230 - Linux: Implement
SingleFileHost
with host and runtime components statically linked.- Statically link
CoreCLR
andClrJIT
withSingleFileHost
Single-File: Implement Linux SingleFileHost with statically linked runtime #37119 Host with coreclr linked in #36847 - Statically link core native libraries with
SingleFileHost
SingleFile: Statically link core native libraries to Linux SingleFileHost #38304
- Statically link
- Windows: Implement
- Runtime
- Load assemblies directly from bundle. Single-File: Implement loading assemblies from bundle #32822 Single-File: Run from Bundle #36052
- Dependency resolution: Resolve assemblies from bundle. Single-File: Run from Bundle #36052
- APIs
-
AppContext.BaseDirectory
should return the location of the single-file executable Single-File: Process bundles in the framework #34274
-
- HostModel library