Support Single-File Apps in .NET 5 (original) (raw)
Navigation Menu
- GitHub Copilot Write better code with AI
- GitHub Models New Manage and compare prompts
- GitHub Advanced Security Find and fix vulnerabilities
- Actions Automate any workflow
- Codespaces Instant dev environments
- Issues Plan and track work
- Code Review Manage code changes
- Discussions Collaborate outside of code
- Code Search Find more, search less
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
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 forPublishSingleFile
. 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 - Host
* Move bundle-processing from the host to the framework . Single-File: Process bundles in the framework #34274
* Processdeps.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: ImplementSingleFileHost
withAppHost
,HostFxr
, andHostPolicy
statically linked. Single-File: Implement statically linked apphost #32823 Build an apphost with hostfxr and hostpolicy linked in #36230
* Linux: ImplementSingleFileHost
with host and runtime components statically linked.
* Statically linkCoreCLR
andClrJIT
withSingleFileHost
Single-File: Implement Linux SingleFileHost with statically linked runtime #37119 Host with coreclr linked in #36847
* Statically link core native libraries withSingleFileHost
SingleFile: Statically link core native libraries to Linux SingleFileHost #38304 - 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