AppHost: Support bundles (stage 1) (dotnet/core-setup#5742)
* 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 https://github.com/dotnet/core-setup/commit/
4a01e55806b0849a08b820518e8cdcbeaaf07476