From 0fec9842dfd654e31140bd2b4c43044b697d1458 Mon Sep 17 00:00:00 2001 From: Senthil Date: Tue, 12 Apr 2016 15:03:36 -0700 Subject: [PATCH] Servicing for hostpolicy --- src/corehost/cli/deps_resolver.cpp | 6 +++--- src/corehost/cli/fxr/fx_muxer.cpp | 32 +++++++++++++++++++----------- src/corehost/cli/fxr/hostfxr.cpp | 22 ++------------------ src/corehost/cli/setup.cmake | 2 +- 4 files changed, 26 insertions(+), 36 deletions(-) diff --git a/src/corehost/cli/deps_resolver.cpp b/src/corehost/cli/deps_resolver.cpp index db0388d7f..686a30360 100644 --- a/src/corehost/cli/deps_resolver.cpp +++ b/src/corehost/cli/deps_resolver.cpp @@ -198,9 +198,9 @@ void deps_resolver_t::setup_probe_config( } // Servicing normal probe. - pal::string_t msil = args.dotnet_extensions; - append_path(&msil, _X("msil")); - m_probes.push_back(probe_config_t::svc(msil, false, false)); + pal::string_t ext_pkgs = args.dotnet_extensions; + append_path(&ext_pkgs, _X("pkgs")); + m_probes.push_back(probe_config_t::svc(ext_pkgs, false, false)); } if (pal::directory_exists(args.dotnet_packages_cache)) diff --git a/src/corehost/cli/fxr/fx_muxer.cpp b/src/corehost/cli/fxr/fx_muxer.cpp index a46cf642c..a9ebde2ed 100644 --- a/src/corehost/cli/fxr/fx_muxer.cpp +++ b/src/corehost/cli/fxr/fx_muxer.cpp @@ -378,24 +378,32 @@ int fx_muxer_t::read_config_and_execute( trace::verbose(_X("Executing as a portable app as per config file [%s]"), config_file.c_str()); pal::string_t fx_dir = (mode == host_mode_t::split_fx) ? own_dir : resolve_fx_dir(own_dir, &config); corehost_init_t init(deps_file, probe_paths, fx_dir, mode, config); - return execute_app(fx_dir, &init, new_argc, new_argv); + + pal::string_t impl_dir; + + // First lookup hostpolicy.dll in servicing with the version of hostpolicy.dll that was compiled lock step with hostfxr. + if (!hostpolicy_exists_in_svc(&impl_dir)) + { + impl_dir = fx_dir; + } + return execute_app(impl_dir, &init, new_argc, new_argv); } else { pal::string_t impl_dir; trace::verbose(_X("Executing as a standalone app as per config file [%s]"), config_file.c_str()); - if (mode == host_mode_t::standalone) + + // First lookup hostpolicy.dll in servicing with the version of hostpolicy.dll that was compiled lock step with hostfxr. + if (!hostpolicy_exists_in_svc(&impl_dir)) { - pal::string_t svc_dir; - impl_dir = hostpolicy_exists_in_svc(&svc_dir) ? svc_dir : own_dir; - } - else if (mode == host_mode_t::split_fx) - { - impl_dir = own_dir; - } - else if (mode == host_mode_t::muxer) - { - impl_dir = get_directory(app_or_deps); + if (mode == host_mode_t::standalone || mode == host_mode_t::split_fx) + { + impl_dir = own_dir; + } + else if (mode == host_mode_t::muxer) + { + impl_dir = get_directory(app_or_deps); + } } trace::verbose(_X("The host impl directory before probing deps is [%s]"), impl_dir.c_str()); if (!library_exists_in_dir(impl_dir, LIBHOSTPOLICY_NAME, nullptr) && !probe_paths.empty() && !deps_file.empty()) diff --git a/src/corehost/cli/fxr/hostfxr.cpp b/src/corehost/cli/fxr/hostfxr.cpp index db99b2807..2db7acfb4 100644 --- a/src/corehost/cli/fxr/hostfxr.cpp +++ b/src/corehost/cli/fxr/hostfxr.cpp @@ -87,15 +87,9 @@ bool hostpolicy_exists_in_svc(pal::string_t* resolved_dir) { pal::string_t svc_dir; pal::get_default_extensions_directory(&svc_dir); + append_path(&svc_dir, _X("pkgs")); pal::string_t version = _STRINGIFY(HOST_POLICY_PKG_VER); - - fx_ver_t lib_ver(-1, -1, -1); - if (!fx_ver_t::parse(version, &lib_ver, false)) - { - return false; - } - pal::string_t rel_dir = _STRINGIFY(HOST_POLICY_PKG_REL_DIR); if (DIR_SEPARATOR != '/') { @@ -104,19 +98,7 @@ bool hostpolicy_exists_in_svc(pal::string_t* resolved_dir) pal::string_t path = svc_dir; append_path(&path, _STRINGIFY(HOST_POLICY_PKG_NAME)); - - pal::string_t max_ver; - if (lib_ver.is_prerelease()) - { - try_prerelease_roll_forward_in_dir(path, lib_ver, &max_ver); - } - else - { - try_patch_roll_forward_in_dir(path, lib_ver, &max_ver); - } - - - append_path(&path, max_ver.c_str()); + append_path(&path, version.c_str()); append_path(&path, rel_dir.c_str()); if (library_exists_in_dir(path, LIBHOSTPOLICY_NAME, nullptr)) diff --git a/src/corehost/cli/setup.cmake b/src/corehost/cli/setup.cmake index b8113aca9..acea35b8e 100644 --- a/src/corehost/cli/setup.cmake +++ b/src/corehost/cli/setup.cmake @@ -71,5 +71,5 @@ if(${CLI_CMAKE_PKG_RID} STREQUAL "") message(FATAL_ERROR "A minimum supported package rid is not specified (ex: win7-x86 or ubuntu.14.04-x64, osx.10.10-x64, rhel.7-x64)") endif() -add_definitions(-DHOST_POLICY_PKG_NAME="Microsoft.NETCore.DotNetHostPolicy") +add_definitions(-DHOST_POLICY_PKG_NAME="runtime.${CLI_CMAKE_PKG_RID}.Microsoft.NETCore.DotNetHostPolicy") add_definitions(-DHOST_POLICY_PKG_REL_DIR="runtimes/${CLI_CMAKE_PKG_RID}/native")