From eabe75750d90e7ce897e3530b34b8b8255caddc4 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Thu, 18 Jul 2019 15:39:36 -0700 Subject: [PATCH] Propagate error writer to hostfxr during delegate acquisition. Commit migrated from https://github.com/dotnet/core-setup/commit/92fb649965eb488cf5918d371cc1d73d323af2ff --- src/installer/corehost/cli/fxr_resolver.h | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/installer/corehost/cli/fxr_resolver.h b/src/installer/corehost/cli/fxr_resolver.h index 643aa82..eec02cc 100644 --- a/src/installer/corehost/cli/fxr_resolver.h +++ b/src/installer/corehost/cli/fxr_resolver.h @@ -77,21 +77,27 @@ int load_fxr_and_get_delegate(hostfxr_delegate_type type, THostPathToConfigCallb dotnet_root.c_str() }; - hostfxr_handle context; - int rc = hostfxr_initialize_for_runtime_config(config_path.c_str(), ¶meters, &context); - if (!STATUS_CODE_SUCCEEDED(rc)) - return rc; - - rc = hostfxr_get_runtime_delegate(context, type, reinterpret_cast(delegate)); + hostfxr_set_error_writer_fn set_error_writer_fn = reinterpret_cast(pal::get_symbol(fxr, "hostfxr_set_error_writer")); - int rcClose = hostfxr_close(context); - if (rcClose != StatusCode::Success) { - assert(false && "Failed to close host context"); - trace::verbose(_X("Failed to close host context: 0x%x"), rcClose); - } + propagate_error_writer_t propagate_error_writer_to_hostfxr(set_error_writer_fn); + + hostfxr_handle context; + int rc = hostfxr_initialize_for_runtime_config(config_path.c_str(), ¶meters, &context); + if (!STATUS_CODE_SUCCEEDED(rc)) + return rc; + + rc = hostfxr_get_runtime_delegate(context, type, reinterpret_cast(delegate)); - return rc; + int rcClose = hostfxr_close(context); + if (rcClose != StatusCode::Success) + { + assert(false && "Failed to close host context"); + trace::verbose(_X("Failed to close host context: 0x%x"), rcClose); + } + + return rc; + } } #endif //_COREHOST_CLI_FXR_RESOLVER_H_ -- 2.7.4