Single-File: Process bundles in the framework (#34274)
authorSwaroop Sridhar <Swaroop.Sridhar@microsoft.com>
Wed, 8 Apr 2020 18:35:03 +0000 (11:35 -0700)
committerGitHub <noreply@github.com>
Wed, 8 Apr 2020 18:35:03 +0000 (11:35 -0700)
commit78b303df8fbb242985d049a277d0d199cafd51b5
tree818486bcb7fb9260793378015d8af40f4d190765
parentf4375ecb7c4a7cf6394b28dd74255ae71830efde
Single-File: Process bundles in the framework (#34274)

* Single-File: Process bundles in the framework

This change implements the host changes proposed in the [design](https://github.com/dotnet/designs/blob/master/accepted/2020/single-file/design.md#startup)

The main changes for single-file bundles are:
* Bundle processing code is moved from apphost to hostpolicy
* HostFxr and HostPolicy process deps.json and runtimeconfig.json files directly from the bundle.
* HostPolicy performs verification wrt deps.json based on the contents of the single-file bundle.
* AppContext.BaseDirectory is set as explained [here](https://github.com/dotnet/designs/blob/master/accepted/2020/single-file/design.md#appcontextbasedirectory)

Currently, all files except deps.json and runtimeconfig.json are extracted to disk.
Once the runtime is able to processing assemblies directly from the bundle, they will no longer be extracted.

Notable details:
* The bundle driver (formarly runner.cpp) is divided into two parts:
   * bundle::info which describes basic information about the bundle available from the headers only
   * bundle::runner which has information about all embedded files, and the ability to drive extraction
  This facilitates linking only parts of the bundle handling code with hostfxr, while all code is linked with hostpolicy.
* The AppHost only links with bundle_marker to identify itself as a single-file bundle.
* If the AppHost is a single-file bundle, it notifies hostfxr using the new hostfxr_main_bundle_startup_info() API
* The HostFxr comminucates the single-file-information with HostPolicy using the host_interface_t structure.

Fixes https://github.com/dotnet/runtime/issues/32821
67 files changed:
src/installer/corehost/cli/apphost/CMakeLists.txt
src/installer/corehost/cli/apphost/bundle/runner.cpp [deleted file]
src/installer/corehost/cli/apphost/bundle/runner.h [deleted file]
src/installer/corehost/cli/apphost/bundle_marker.cpp [moved from src/installer/corehost/cli/apphost/bundle/marker.cpp with 86% similarity]
src/installer/corehost/cli/apphost/bundle_marker.h [moved from src/installer/corehost/cli/apphost/bundle/marker.h with 83% similarity]
src/installer/corehost/cli/bundle/dir_utils.cpp [moved from src/installer/corehost/cli/apphost/bundle/dir_utils.cpp with 100% similarity]
src/installer/corehost/cli/bundle/dir_utils.h [moved from src/installer/corehost/cli/apphost/bundle/dir_utils.h with 100% similarity]
src/installer/corehost/cli/bundle/extractor.cpp [moved from src/installer/corehost/cli/apphost/bundle/extractor.cpp with 98% similarity]
src/installer/corehost/cli/bundle/extractor.h [moved from src/installer/corehost/cli/apphost/bundle/extractor.h with 100% similarity]
src/installer/corehost/cli/bundle/file_entry.cpp [moved from src/installer/corehost/cli/apphost/bundle/file_entry.cpp with 77% similarity]
src/installer/corehost/cli/bundle/file_entry.h [moved from src/installer/corehost/cli/apphost/bundle/file_entry.h with 98% similarity]
src/installer/corehost/cli/bundle/file_type.h [moved from src/installer/corehost/cli/apphost/bundle/file_type.h with 100% similarity]
src/installer/corehost/cli/bundle/header.cpp [moved from src/installer/corehost/cli/apphost/bundle/header.cpp with 53% similarity]
src/installer/corehost/cli/bundle/header.h [moved from src/installer/corehost/cli/apphost/bundle/header.h with 76% similarity]
src/installer/corehost/cli/bundle/info.cpp [new file with mode: 0644]
src/installer/corehost/cli/bundle/info.h [new file with mode: 0644]
src/installer/corehost/cli/bundle/manifest.cpp [moved from src/installer/corehost/cli/apphost/bundle/manifest.cpp with 71% similarity]
src/installer/corehost/cli/bundle/manifest.h [moved from src/installer/corehost/cli/apphost/bundle/manifest.h with 76% similarity]
src/installer/corehost/cli/bundle/reader.cpp [moved from src/installer/corehost/cli/apphost/bundle/reader.cpp with 88% similarity]
src/installer/corehost/cli/bundle/reader.h [moved from src/installer/corehost/cli/apphost/bundle/reader.h with 74% similarity]
src/installer/corehost/cli/bundle/runner.cpp [new file with mode: 0644]
src/installer/corehost/cli/bundle/runner.h [new file with mode: 0644]
src/installer/corehost/cli/deps_entry.cpp
src/installer/corehost/cli/deps_entry.h
src/installer/corehost/cli/deps_format.cpp
src/installer/corehost/cli/fxr/command_line.cpp
src/installer/corehost/cli/fxr/corehost_init.cpp
src/installer/corehost/cli/fxr/corehost_init.h
src/installer/corehost/cli/fxr/fx_muxer.cpp
src/installer/corehost/cli/fxr/hostfxr.cpp
src/installer/corehost/cli/fxr/hostpolicy_resolver.cpp
src/installer/corehost/cli/host_interface.h
src/installer/corehost/cli/host_startup_info.h
src/installer/corehost/cli/hostcommon/CMakeLists.txt
src/installer/corehost/cli/hostfxr.h
src/installer/corehost/cli/hostmisc/pal.h
src/installer/corehost/cli/hostmisc/pal.unix.cpp
src/installer/corehost/cli/hostmisc/pal.windows.cpp
src/installer/corehost/cli/hostmisc/utils.cpp
src/installer/corehost/cli/hostmisc/utils.h
src/installer/corehost/cli/hostpolicy/CMakeLists.txt
src/installer/corehost/cli/hostpolicy/args.cpp
src/installer/corehost/cli/hostpolicy/deps_resolver.cpp
src/installer/corehost/cli/hostpolicy/deps_resolver.h
src/installer/corehost/cli/hostpolicy/hostpolicy.cpp
src/installer/corehost/cli/hostpolicy/hostpolicy_init.cpp
src/installer/corehost/cli/hostpolicy/hostpolicy_init.h
src/installer/corehost/cli/ijwhost/ijwthunk.cpp
src/installer/corehost/cli/json/rapidjson/document.h
src/installer/corehost/cli/json_parser.cpp
src/installer/corehost/cli/json_parser.h
src/installer/corehost/cli/runtime_config.cpp
src/installer/corehost/cli/test/mockhostpolicy/mockhostpolicy.cpp
src/installer/corehost/corehost.cpp
src/installer/managed/Microsoft.NET.HostModel/Bundle/Bundler.cs
src/installer/managed/Microsoft.NET.HostModel/Bundle/Manifest.cs
src/installer/managed/Microsoft.NET.HostModel/Bundle/TargetInfo.cs
src/installer/test/Assets/TestProjects/AppWithSubDirs/Program.cs
src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundleExtractToSpecificPath.cs
src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundleRename.cs
src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs
src/installer/test/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs
src/installer/test/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Bundle.Tests/BundleAndRun.cs
src/installer/test/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Bundle.Tests/BundleLegacy.cs
src/installer/test/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Bundle.Tests/BundlerConsistencyTests.cs
src/installer/test/TestUtils/TestApp.cs
src/installer/test/TestUtils/TestProject.cs