Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

AppHost: Support bundles (stage 1) #5742

Merged
merged 6 commits into from
Apr 14, 2019
Merged

Conversation

swaroop-sridhar
Copy link

@swaroop-sridhar swaroop-sridhar commented Apr 9, 2019

This changes implements the app-host support for executing .net core apps published as a single file.

This change implements stage 1, which extracts out the embedded files to disk.

On startup, the AppHost detects whether it's own binary is a .net core bundle.
If so, on the first run, the host extracts embedded files to:

  • $DOTNET_BUNDLE_EXTRACT_BASE_DIR/app/id/... if DOTNET_BUNDLE_EXTRACT_BASE_DIR is set
  • $TMPDIR/.net/app/id/... otherwise.

On subsequent runs, the files extracted above are reused.

AppHost (X64) size increase:
Windows 5KB, Linux 11KB, Mac 6KB

Testing:
Tested the single-file extraction locally with several kinds of dotnet apps
(wpf, winforms, web, mvc, console, etc.)
Added a test case that runs a bundled apps with sub directories

src/corehost/cli/bdl_file_entry.h Outdated Show resolved Hide resolved
src/corehost/cli/bdl_file_entry.cpp Outdated Show resolved Hide resolved
src/corehost/cli/bdl_file_entry.cpp Outdated Show resolved Hide resolved
src/corehost/cli/bdl_file_entry.cpp Outdated Show resolved Hide resolved
src/corehost/cli/bdl_file_entry.cpp Outdated Show resolved Hide resolved
src/corehost/common/pal.windows.cpp Outdated Show resolved Hide resolved
src/corehost/corehost.cpp Outdated Show resolved Hide resolved
src/corehost/corehost.cpp Outdated Show resolved Hide resolved
src/corehost/corehost.cpp Outdated Show resolved Hide resolved
src/corehost/corehost.cpp Outdated Show resolved Hide resolved
@swaroop-sridhar
Copy link
Author

Thanks for the detailed feedback @vitek-karas.

@swaroop-sridhar
Copy link
Author

@vitek-karas I've committed the changes except file renames/moves in this change d181371
I'll commit another change that does the file moves, because that obscures the diffing. Thanks.

@swaroop-sridhar
Copy link
Author

@vitek-karas with the latest commit, I believe I've addressed all of your comments. Thanks.

src/corehost/common/pal.windows.cpp Outdated Show resolved Hide resolved
src/corehost/corehost.cpp Outdated Show resolved Hide resolved
src/corehost/cli/bdl_processor.cpp Outdated Show resolved Hide resolved
src/corehost/cli/apphost/CMakeLists.txt Show resolved Hide resolved
src/corehost/cli/apphost/CMakeLists.txt Outdated Show resolved Hide resolved
@swaroop-sridhar
Copy link
Author

Thanks @vitek-karas, I've addressed your comments in this checkin: 2f379ec

Copy link
Member

@vitek-karas vitek-karas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@swaroop-sridhar swaroop-sridhar force-pushed the host branch 2 times, most recently from 679d686 to fe3316a Compare April 13, 2019 03:11
swaroop-sridhar and others added 6 commits April 13, 2019 16:35
This changes implements the [app-host support](https://github.com/dotnet/designs/blob/master/accepted/single-file/design.md#the-host )
for executing .net core apps published as a single file.

This change implements [stage 1](https://github.com/dotnet/designs/blob/master/accepted/single-file/staging.md#1-self-extractor),
which [extracts out](https://github.com/dotnet/designs/blob/master/accepted/single-file/extract.md ) the embedded files to disk.

On startup, the AppHost detects whether it's own binary is a .net core bundle.
If so, on the first run, the host extracts embedded files to:
  * $DOTNET_BUNDLE_EXTRACT_BASE_DIR/.net/<app>/<id>/... if DOTNET_BUNDLE_EXTRACT_BASE_DIR is set
  * $TMPDIR/.net/<app>/<id>/... otherwise.

On subsequent runs, the files extracted above are reused.

AppHost (X64) size increase:
Windows 5KB
Linux 11KB
Mac 6KB

Testing:
Tested the single-file extraction locally with several kinds of dotnet apps
(wpf, winforms, web, mvc, console, etc.)
Added a test case that runs a bundled apps with sub directories

Add a test for processing bundles
* Use spaces instead of tabs for indentation
* Fix trace messages
* Fix some rebasing problems
* Improve pal::get_temp_dir() on windows.
* Fix a few minor issues (function ordering etc)
* Read/Write file extraction in 8KB chunks
* Also fix a bug in the extractor for a similar issue.
* Rename bundle processor to bundle runner
On Ubuntu, $TMPDIR is not set. So, add an option to try
/var/tmp or /tmp directories.
@swaroop-sridhar
Copy link
Author

@vitek-karas I had to make another small change: 3de5b31 to get tmp-directory on Ubuntu.

@swaroop-sridhar swaroop-sridhar merged commit 4a01e55 into dotnet:master Apr 14, 2019
@swaroop-sridhar
Copy link
Author

@vitek-karas, I merged the change, in order to facilitate its flow into SDK repo, where I have other changes to be tested with this AppHost. If you have any concerns with 3de5b31, I'll address it separately. I'm also planning to put out another PR with more test cases.

@swaroop-sridhar swaroop-sridhar deleted the host branch April 14, 2019 06:32
@vitek-karas
Copy link
Member

@swaroop-sridhar Thanks! LGTM

picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* AppHost: Support bundles (stage 1)

This changes implements the [app-host support](https://github.com/dotnet/designs/blob/master/accepted/single-file/design.md#the-host )
for executing .net core apps published as a single file.

This change implements [stage 1](https://github.com/dotnet/designs/blob/master/accepted/single-file/staging.mddotnet/core-setup#1-self-extractor),
which [extracts out](https://github.com/dotnet/designs/blob/master/accepted/single-file/extract.md ) the embedded files to disk.

On startup, the AppHost detects whether it's own binary is a .net core bundle.
If so, on the first run, the host extracts embedded files to:
  * if `DOTNET_BUNDLE_EXTRACT_BASE_DIR` is set, to `$DOTNET_BUNDLE_EXTRACT_BASE_DIR/.net/<app>/<id>/...` . Otherwise, 
  * On Windows, to `%TEMP%/.net/<app>/<id>/...`
  * On Unix systems, if `$TMPDIR` is set, to `$TMPDIR/.net/<app>/<id>/...` . Otherwise to `/var/tmp` or `/tmp` if those paths are available and accessible.

On subsequent runs, the files extracted above are reused.

AppHost (X64) size increase:
Windows 5KB
Linux 11KB
Mac 6KB

Testing:
Tested the single-file extraction locally with several kinds of dotnet apps
(wpf, winforms, web, mvc, console, etc.)
Added a test case that runs a bundled apps with sub directories
Also fixed a bug in the Microsoft.NET.HostModel.extractor wrt processing bundled files in chunks.


Commit migrated from dotnet/core-setup@4a01e55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants