commit
3742f5c4a8
10 changed files with 95 additions and 40 deletions
|
@ -28,7 +28,7 @@ bool parse_arguments(
|
|||
// Get the full name of the application
|
||||
if (!pal::get_own_executable_path(&args.own_path) || !pal::realpath(&args.own_path))
|
||||
{
|
||||
trace::error(_X("Failed to locate current executable"));
|
||||
trace::error(_X("Failed to resolve full path of the current executable [%s]"), args.own_path.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ bool parse_arguments(
|
|||
args.managed_application = pal::string_t(argv[1]);
|
||||
if (!pal::realpath(&args.managed_application))
|
||||
{
|
||||
trace::error(_X("Failed to locate managed application: %s"), args.managed_application.c_str());
|
||||
trace::error(_X("Failed to locate managed application [%s]"), args.managed_application.c_str());
|
||||
return false;
|
||||
}
|
||||
args.app_dir = get_directory(args.managed_application);
|
||||
|
@ -62,7 +62,7 @@ bool parse_arguments(
|
|||
args.managed_application = managed_app;
|
||||
if (!pal::realpath(&args.managed_application))
|
||||
{
|
||||
trace::error(_X("Failed to locate managed application: %s"), args.managed_application.c_str());
|
||||
trace::error(_X("Failed to locate managed application [%s]"), args.managed_application.c_str());
|
||||
return false;
|
||||
}
|
||||
args.app_dir = own_dir;
|
||||
|
|
|
@ -93,7 +93,7 @@ void deps_json_t::reconcile_libraries_with_targets(
|
|||
entry.asset_name == LIBCORECLR_FILENAME)
|
||||
{
|
||||
m_coreclr_index = m_deps_entries[i].size() - 1;
|
||||
trace::verbose(_X("Found coreclr from deps %d [%s, %s, %s]"),
|
||||
trace::verbose(_X("Found CoreCLR from deps %d [%s, %s, %s]"),
|
||||
m_coreclr_index,
|
||||
entry.library_name.c_str(),
|
||||
entry.library_version.c_str(),
|
||||
|
@ -134,16 +134,18 @@ bool deps_json_t::perform_rid_fallback(rid_specific_assets_t* portable_assets, c
|
|||
{
|
||||
if (rid_fallback_graph.count(host_rid) == 0)
|
||||
{
|
||||
trace::error(_X("Did not find fallback rids for package %s for the host rid %s"), package.first.c_str(), host_rid.c_str());
|
||||
return false;
|
||||
trace::warning(_X("The targeted framework does not support the runtime '%s'. Some native libraries from [%s] may fail to load on this platform."), host_rid.c_str(), package.first.c_str());
|
||||
}
|
||||
const auto& fallback_rids = rid_fallback_graph.find(host_rid)->second;
|
||||
auto iter = std::find_if(fallback_rids.begin(), fallback_rids.end(), [&package](const pal::string_t& rid) {
|
||||
return package.second.rid_assets.count(rid);
|
||||
});
|
||||
if (iter != fallback_rids.end())
|
||||
else
|
||||
{
|
||||
matched_rid = *iter;
|
||||
const auto& fallback_rids = rid_fallback_graph.find(host_rid)->second;
|
||||
auto iter = std::find_if(fallback_rids.begin(), fallback_rids.end(), [&package](const pal::string_t& rid) {
|
||||
return package.second.rid_assets.count(rid);
|
||||
});
|
||||
if (iter != fallback_rids.end())
|
||||
{
|
||||
matched_rid = *iter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -350,7 +352,7 @@ bool deps_json_t::load(bool portable, const pal::string_t& deps_path, const rid_
|
|||
// If file doesn't exist, then assume parsed.
|
||||
if (!pal::file_exists(deps_path))
|
||||
{
|
||||
trace::verbose(_X("Deps file does not exist [%s]"), deps_path.c_str());
|
||||
trace::verbose(_X("Could not locate the dependencies manifest file [%s]. Some libraries may fail to resolve."), deps_path.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -358,7 +360,7 @@ bool deps_json_t::load(bool portable, const pal::string_t& deps_path, const rid_
|
|||
pal::ifstream_t file(deps_path);
|
||||
if (!file.good())
|
||||
{
|
||||
trace::error(_X("Could not open file stream on deps file [%s]"), deps_path.c_str());
|
||||
trace::error(_X("Could not open dependencies manifest file [%s]"), deps_path.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -328,6 +328,8 @@ bool deps_resolver_t::probe_entry_in_configs(const deps_entry_t& entry, pal::str
|
|||
//
|
||||
pal::string_t deps_resolver_t::resolve_coreclr_dir()
|
||||
{
|
||||
trace::verbose(_X("--- Resolving CoreCLR directory ---"));
|
||||
|
||||
auto process_coreclr = [&]
|
||||
(bool is_portable, const pal::string_t& deps_dir, deps_json_t* deps) -> pal::string_t
|
||||
{
|
||||
|
@ -347,7 +349,7 @@ pal::string_t deps_resolver_t::resolve_coreclr_dir()
|
|||
}
|
||||
else
|
||||
{
|
||||
trace::verbose(_X("Deps has no coreclr entry."));
|
||||
trace::verbose(_X("Deps has no CoreCLR entry."));
|
||||
}
|
||||
|
||||
// App/FX main dir or standalone app dir.
|
||||
|
@ -432,7 +434,7 @@ void deps_resolver_t::resolve_tpa_list(
|
|||
else
|
||||
{
|
||||
// FIXME: Consider this error as a fail fast?
|
||||
trace::verbose(_X("Error: Could not resolve path to assembly: [%s, %s, %s]"), entry.library_name.c_str(), entry.library_version.c_str(), entry.relative_path.c_str());
|
||||
trace::warning(_X("Could not resolve path to assembly: [%s, %s, %s]"), entry.library_name.c_str(), entry.library_version.c_str(), entry.relative_path.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -50,8 +50,21 @@ public:
|
|||
setup_probe_config(init, args);
|
||||
}
|
||||
|
||||
bool valid() { return m_deps->is_valid() && (!m_portable || m_fx_deps->is_valid()); }
|
||||
|
||||
bool valid(pal::string_t* errors)
|
||||
{
|
||||
if (!m_deps->is_valid())
|
||||
{
|
||||
errors->assign(_X("An error occurred while parsing ") + m_deps_file);
|
||||
return false;
|
||||
}
|
||||
if (m_portable && !m_fx_deps->is_valid())
|
||||
{
|
||||
errors->assign(_X("An error occurred while parsing ") + m_fx_deps_file);
|
||||
return false;
|
||||
}
|
||||
errors->clear();
|
||||
return true;
|
||||
}
|
||||
void setup_probe_config(
|
||||
const hostpolicy_init_t& init,
|
||||
const arguments_t& args);
|
||||
|
|
|
@ -285,7 +285,11 @@ int fx_muxer_t::parse_args_and_execute(
|
|||
std::unordered_map<pal::string_t, std::vector<pal::string_t>> opts;
|
||||
if (!parse_known_args(argc - argoff, &argv[argoff], known_opts, &opts, &num_parsed))
|
||||
{
|
||||
trace::error(_X("Failed to parse supported arguments."));
|
||||
trace::error(_X("Failed to parse supported options or their values:"));
|
||||
for (const auto& arg : known_opts)
|
||||
{
|
||||
trace::error(_X(" %s"), arg.c_str());
|
||||
}
|
||||
return InvalidArgFailure;
|
||||
}
|
||||
|
||||
|
@ -296,7 +300,7 @@ int fx_muxer_t::parse_args_and_execute(
|
|||
int cur_i = argoff + num_parsed;
|
||||
if (mode != host_mode_t::standalone)
|
||||
{
|
||||
trace::verbose(_X("App not in standalone mode, so expecting more arguments..."));
|
||||
trace::verbose(_X("Detected a non-standalone application, expecting app.dll to execute."));
|
||||
if (cur_i >= argc)
|
||||
{
|
||||
return muxer_usage();
|
||||
|
@ -310,7 +314,7 @@ int fx_muxer_t::parse_args_and_execute(
|
|||
{
|
||||
if (!is_app_runnable)
|
||||
{
|
||||
trace::error(_X("dotnet exec needs a dll to execute. Try dotnet [--help]"));
|
||||
trace::error(_X("dotnet exec needs a .dll or .exe to execute. See usage."));
|
||||
*is_an_app = false;
|
||||
return InvalidArgFailure;
|
||||
}
|
||||
|
@ -448,7 +452,11 @@ int fx_muxer_t::read_config_and_execute(
|
|||
}
|
||||
if (!found)
|
||||
{
|
||||
trace::error(_X("Policy library either not found in deps [%s] or not found in %d probe paths."), deps_file.c_str(), probe_realpaths.size());
|
||||
trace::error(_X("Could not find required library %s in the dependencies manifest [%s] or in %d probing paths: "), LIBHOSTPOLICY_NAME, deps_file.c_str(), probe_realpaths.size());
|
||||
for (const auto& path : probe_realpaths)
|
||||
{
|
||||
trace::error(_X(" %s"), path.c_str());
|
||||
}
|
||||
return StatusCode::CoreHostLibMissingFailure;
|
||||
}
|
||||
impl_dir = get_directory(candidate);
|
||||
|
@ -466,7 +474,7 @@ int fx_muxer_t::execute(const int argc, const pal::char_t* argv[])
|
|||
// Get the full name of the application
|
||||
if (!pal::get_own_executable_path(&own_path) || !pal::realpath(&own_path))
|
||||
{
|
||||
trace::error(_X("Failed to locate current executable"));
|
||||
trace::error(_X("Failed to resolve full path of the current executable [%s]"), own_path.c_str());
|
||||
return StatusCode::LibHostCurExeFindFailure;
|
||||
}
|
||||
pal::string_t own_name = get_filename(own_path);
|
||||
|
|
|
@ -45,6 +45,38 @@ int load_host_library(
|
|||
: StatusCode::CoreHostEntryPointFailure;
|
||||
}
|
||||
|
||||
void handle_missing_framework_error(const corehost_init_t* init)
|
||||
{
|
||||
pal::string_t name = init->fx_name();
|
||||
pal::string_t version = init->fx_version();
|
||||
pal::string_t fx_ver_dirs = get_directory(init->fx_dir());
|
||||
|
||||
trace::error(_X("The targeted framework { \"%s\": \"%s\" } was not found."), name.c_str(), version.c_str());
|
||||
trace::error(_X(" - Check application dependencies and target a framework version installed at:"));
|
||||
trace::error(_X(" %s"), fx_ver_dirs.c_str());
|
||||
|
||||
bool header = true;
|
||||
std::vector<pal::string_t> versions;
|
||||
pal::readdir(fx_ver_dirs, &versions);
|
||||
for (const auto& ver : versions)
|
||||
{
|
||||
fx_ver_t parsed(-1, -1, -1);
|
||||
if (fx_ver_t::parse(ver, &parsed, false))
|
||||
{
|
||||
if (header)
|
||||
{
|
||||
trace::error(_X(" - The following versions are installed:"));
|
||||
header = false;
|
||||
}
|
||||
trace::error(_X(" %s"), ver.c_str());
|
||||
}
|
||||
}
|
||||
if (header)
|
||||
{
|
||||
trace::error(_X(" - Or install the framework version that is being targeted."));
|
||||
}
|
||||
}
|
||||
|
||||
int execute_app(
|
||||
const pal::string_t& impl_dll_dir,
|
||||
corehost_init_t* init,
|
||||
|
@ -60,17 +92,14 @@ int execute_app(
|
|||
|
||||
if (code != StatusCode::Success)
|
||||
{
|
||||
trace::error(_X("Expected to load %s from [%s]"), LIBHOSTPOLICY_NAME, impl_dll_dir.c_str());
|
||||
if (init->fx_dir() == impl_dll_dir)
|
||||
{
|
||||
pal::string_t name = init->fx_name();
|
||||
pal::string_t version = init->fx_version();
|
||||
trace::error(_X("This may be because the targeted framework [\"%s\": \"%s\"] was not found."),
|
||||
name.c_str(), version.c_str());
|
||||
handle_missing_framework_error(init);
|
||||
}
|
||||
else
|
||||
{
|
||||
trace::error(_X("This may be because of an invalid .NET Core FX configuration in the folder."));
|
||||
trace::error(_X("Expected to load required %s from [%s]"), LIBHOSTPOLICY_NAME, impl_dll_dir.c_str());
|
||||
trace::error(_X(" - This may be because of an invalid .NET Core FX configuration in the directory."));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -20,16 +20,17 @@ int run(const arguments_t& args)
|
|||
// Load the deps resolver
|
||||
deps_resolver_t resolver(g_init, args);
|
||||
|
||||
if (!resolver.valid())
|
||||
pal::string_t resolver_errors;
|
||||
if (!resolver.valid(&resolver_errors))
|
||||
{
|
||||
trace::error(_X("Invalid .deps file"));
|
||||
trace::error(_X("Error initializing the dependency resolver: %s"), resolver_errors.c_str());
|
||||
return StatusCode::ResolverInitFailure;
|
||||
}
|
||||
|
||||
pal::string_t clr_path = resolver.resolve_coreclr_dir();
|
||||
if (clr_path.empty() || !pal::realpath(&clr_path))
|
||||
{
|
||||
trace::error(_X("Could not resolve coreclr path"));
|
||||
trace::error(_X("Could not resolve CoreCLR path. For more details, enable tracing by setting COREHOST_TRACE environment variable to 1"));;
|
||||
return StatusCode::CoreClrResolveFailure;
|
||||
}
|
||||
else
|
||||
|
@ -112,7 +113,7 @@ int run(const arguments_t& args)
|
|||
// Bind CoreCLR
|
||||
if (!coreclr::bind(clr_path))
|
||||
{
|
||||
trace::error(_X("Failed to bind to coreclr"));
|
||||
trace::error(_X("Failed to bind to CoreCLR at [%s]"), clr_path.c_str());
|
||||
return StatusCode::CoreClrBindFailure;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ bool pal::touch_file(const pal::string_t& path)
|
|||
int fd = open(path.c_str(), (O_CREAT | O_EXCL), (S_IRUSR | S_IRGRP | S_IROTH));
|
||||
if (fd == -1)
|
||||
{
|
||||
trace::warning(_X("Failed to open() file descriptor in %s(%s)"), __FUNCTION__, path.c_str());
|
||||
trace::warning(_X("open(%s) failed in %s"), path.c_str(), _STRINGIFY(__FUNCTION__));
|
||||
return false;
|
||||
}
|
||||
(void) close(fd);
|
||||
|
|
|
@ -133,7 +133,7 @@ bool pal::load_library(const char_t* path, dll_t* dll)
|
|||
*dll = ::LoadLibraryExW(path, NULL, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
|
||||
if (*dll == nullptr)
|
||||
{
|
||||
trace::error(_X("Failed to load the dll from %s, HRESULT: 0x%X"), path, HRESULT_FROM_WIN32(GetLastError()));
|
||||
trace::error(_X("Failed to load the dll from [%s], HRESULT: 0x%X"), path, HRESULT_FROM_WIN32(GetLastError()));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ bool pal::load_library(const char_t* path, dll_t* dll)
|
|||
HMODULE dummy_module;
|
||||
if (!::GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_PIN, path, &dummy_module))
|
||||
{
|
||||
trace::error(_X("Failed to pin library: %s"));
|
||||
trace::error(_X("Failed to pin library [%s] in [%s]"), path, _STRINGIFY(__FUNCTION__));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -218,14 +218,14 @@ bool pal::getenv(const char_t* name, string_t* recv)
|
|||
auto err = GetLastError();
|
||||
if (err != ERROR_ENVVAR_NOT_FOUND)
|
||||
{
|
||||
trace::error(_X("Failed to read environment variable '%s', HRESULT: 0x%X"), name, HRESULT_FROM_WIN32(GetLastError()));
|
||||
trace::error(_X("Failed to read environment variable [%s], HRESULT: 0x%X"), name, HRESULT_FROM_WIN32(GetLastError()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
auto buf = new char_t[length];
|
||||
if (::GetEnvironmentVariableW(name, buf, length) == 0)
|
||||
{
|
||||
trace::error(_X("Failed to read environment variable '%s', HRESULT: 0x%X"), name, HRESULT_FROM_WIN32(GetLastError()));
|
||||
trace::error(_X("Failed to read environment variable [%s], HRESULT: 0x%X"), name, HRESULT_FROM_WIN32(GetLastError()));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -295,7 +295,7 @@ bool pal::realpath(string_t* path)
|
|||
auto res = ::GetFullPathNameW(path->c_str(), MAX_PATH, buf, nullptr);
|
||||
if (res == 0 || res > MAX_PATH)
|
||||
{
|
||||
trace::error(_X("Error resolving path: %s"), path->c_str());
|
||||
trace::error(_X("Error resolving full path [%s]"), path->c_str());
|
||||
return false;
|
||||
}
|
||||
path->assign(buf);
|
||||
|
|
|
@ -63,7 +63,7 @@ int run(const int argc, const pal::char_t* argv[])
|
|||
pal::string_t own_path;
|
||||
if (!pal::get_own_executable_path(&own_path) || !pal::realpath(&own_path))
|
||||
{
|
||||
trace::error(_X("Failed to locate current executable"));
|
||||
trace::error(_X("Failed to resolve full path of the current executable [%s]"), own_path.c_str());
|
||||
return StatusCode::CoreHostCurExeFindFailure;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue