Skip to content

Use SingleFileHost for self-contained single-file apps #11567

@swaroop-sridhar

Description

@swaroop-sridhar

There are two main tasks that need to be done for self-contained single-file publish scenario:

Use singlefilehost

  • @VSadov's PR adds singlefilehost to the microsoft.netcore.app.host.* packages.
  • ResolveAppHosts will resolve singlefilehost to the same package as apphost, ijwhost, and comhost.
  • When publishing for self-contained single-file apps, the CreateAppHost task will be invoked with the singlefilehost path as its AppHostSourcePath. This will generate an app using singlefilehost.
  • This may not work very well for a sequence such below. However, I think fixing this case is not crucial, because the --no-build already has similar concerns for self-contained vs framework-dependent publish.
    dotnet build -r win-x64 
    dotnet publish --no-build -r win-x64 /p:PublishSingleFile=true.

Trim the native components of the runtime:

  • Certain files in microsoft.netcore.app.runtime.* package are no longer necessary to be published for single-file apps.
  • For example, hostfxr and hostpolicy are not necessary since they are statically linked with singlefilehost. Later coreclr, clrjit will also be linked with the singlefilehost, and they are also not necessary. Certain other files such as createdump are excluded from the publish as a matter of policy decision.
  • This exclusion is different from ExcludeFromSingleFile
    • In this case, the files, the excluded files are not published at all (neither in the bundle nor in the publish directory beside the single-file bundle).
    • Files marked ExcludeFromSingleFile are copied to publish directory alongside the single-file app.
  • The plan to realize this exclusion of runtime components is:
    • The RuntimeList.xml in microsoft.netcore.app.runtime.* package will contain special meta-data identifying that the file is not necessary for single-file scenario
      <File FileVersion="0.0.0.0" Path="runtimes/linux-x64/native/createdump" Type="Native" DropFromSingleFile="true"/>
    • The ResolveRuntimePackAssets task will transfer this annotation as (DropFromSingleFile) meta-data on the asset.
    • The Single-file publish targets will use this meta-data to drop these files, and not publish them in the single-file app.

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions