diff --git a/src/corehost/cli/deps_entry.cpp b/src/corehost/cli/deps_entry.cpp index ff5ebbbe3..0eceb9898 100644 --- a/src/corehost/cli/deps_entry.cpp +++ b/src/corehost/cli/deps_entry.cpp @@ -6,6 +6,7 @@ #include "deps_entry.h" #include "trace.h" + // ----------------------------------------------------------------------------- // Given a "base" directory, yield the relative path of this file in the package // layout. @@ -18,7 +19,7 @@ // Returns: // If the file exists in the path relative to the "base" directory. // -bool deps_entry_t::to_full_path(const pal::string_t& base, pal::string_t* str) const +bool deps_entry_t::to_rel_path(const pal::string_t& base, pal::string_t* str) const { pal::string_t& candidate = *str; @@ -40,23 +41,53 @@ bool deps_entry_t::to_full_path(const pal::string_t& base, pal::string_t* str) c // Reserve space for the path below candidate.reserve(base.length() + - library_name.length() + - library_version.length() + pal_relative_path.length() + 3); candidate.assign(base); - append_path(&candidate, library_name.c_str()); - append_path(&candidate, library_version.c_str()); append_path(&candidate, pal_relative_path.c_str()); bool exists = pal::file_exists(candidate); if (!exists) { + trace::verbose(_X("Relative path query did not exist %s"), candidate.c_str()); candidate.clear(); } + else + { + trace::verbose(_X("Relative path query exists %s"), candidate.c_str()); + } return exists; } +// ----------------------------------------------------------------------------- +// Given a "base" directory, yield the relative path of this file in the package +// layout. +// +// Parameters: +// base - The base directory to look for the relative path of this entry +// str - If the method returns true, contains the file path for this deps +// entry relative to the "base" directory +// +// Returns: +// If the file exists in the path relative to the "base" directory. +// +bool deps_entry_t::to_full_path(const pal::string_t& base, pal::string_t* str) const +{ + str->clear(); + + // Base directory must be present to obtain full path + if (base.empty()) + { + return false; + } + + pal::string_t new_base = base; + append_path(&new_base, library_name.c_str()); + append_path(&new_base, library_version.c_str()); + + return to_rel_path(new_base, str); +} + // ----------------------------------------------------------------------------- // Given a "base" directory, yield the relative path of this file in the package // layout if the entry hash matches the hash file in the "base" directory diff --git a/src/corehost/cli/deps_entry.h b/src/corehost/cli/deps_entry.h index 81e30e541..3b5c616cc 100644 --- a/src/corehost/cli/deps_entry.h +++ b/src/corehost/cli/deps_entry.h @@ -28,9 +28,12 @@ struct deps_entry_t bool is_serviceable; // Given a "base" dir, yield the relative path in the package layout. + bool to_rel_path(const pal::string_t& base, pal::string_t* str) const; + + // Given a "base" dir, yield the relative path with package name, version in the package layout. bool to_full_path(const pal::string_t& root, pal::string_t* str) const; - // Given a "base" dir, yield the relative path in the package layout only if + // Given a "base" dir, yield the relative path with package name, version in the package layout only if // the hash matches contents of the hash file. bool to_hash_matched_path(const pal::string_t& root, pal::string_t* str) const; }; diff --git a/src/corehost/cli/deps_resolver.cpp b/src/corehost/cli/deps_resolver.cpp index eca47422d..167fc5107 100644 --- a/src/corehost/cli/deps_resolver.cpp +++ b/src/corehost/cli/deps_resolver.cpp @@ -286,6 +286,8 @@ void deps_resolver_t::resolve_tpa_list( pal::string_t candidate; + trace::info(_X("Processing TPA for deps entry [%s, %s, %s]"), entry.library_name.c_str(), entry.library_version.c_str(), entry.relative_path.c_str()); + // Is this a serviceable entry and is there an entry in the servicing index? if (entry.is_serviceable && entry.library_type == _X("Package") && m_svc.find_redirection(entry.library_name, entry.library_version, entry.relative_path, &candidate)) @@ -303,7 +305,7 @@ void deps_resolver_t::resolve_tpa_list( add_tpa_asset(entry.asset_name, candidate, &items, output); } // The app is portable so the rid asset should be picked up from relative subpath. - else if (is_portable && deps->try_ni(entry).to_full_path(app_dir, &candidate)) + else if (is_portable && deps->try_ni(entry).to_rel_path(app_dir, &candidate)) { add_tpa_asset(entry.asset_name, candidate, &items, output); } @@ -421,21 +423,21 @@ void deps_resolver_t::resolve_probe_dirs( std::for_each(fx_entries.begin(), fx_entries.end(), add_package_cache_entry); } - // App local path - add_unique_path(asset_type, app_dir, &items, output); - // For portable path, the app relative directory must be used. if (m_portable) { std::for_each(entries.begin(), entries.end(), [&](const deps_entry_t& entry) { - if (entry.asset_type == asset_type && entry.to_full_path(package_dir, &candidate)) + if (entry.asset_type == asset_type && entry.to_rel_path(app_dir, &candidate)) { add_unique_path(asset_type, action(candidate), &items, output); } }); } + // App local path + add_unique_path(asset_type, app_dir, &items, output); + // FX path if present if (!m_fx_dir.empty()) {