diff --git a/src/coreclr/binder/assemblybindercommon.cpp b/src/coreclr/binder/assemblybindercommon.cpp index afa78e43b26a0c..a77c53658a6a4e 100644 --- a/src/coreclr/binder/assemblybindercommon.cpp +++ b/src/coreclr/binder/assemblybindercommon.cpp @@ -22,7 +22,6 @@ #include "failurecache.hpp" #include "utils.hpp" #include "stringarraylist.h" -#include "configuration.h" #if !defined(DACCESS_COMPILE) #include "defaultassemblybinder.h" @@ -295,37 +294,16 @@ namespace BINDER_SPACE BinderTracing::PathProbed(sCoreLib, pathSource, hr); - if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) + if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) + && Bundle::AppIsBundle() + && Bundle::AppBundle->HasExtractedFiles()) { - // Try to find corelib in the TPA - StackSString sCoreLibSimpleName(CoreLibName_W); - StackSString sTrustedPlatformAssemblies = Configuration::GetKnobStringValue(W("TRUSTED_PLATFORM_ASSEMBLIES")); - sTrustedPlatformAssemblies.Normalize(); - - bool found = false; - for (SString::Iterator i = sTrustedPlatformAssemblies.Begin(); i != sTrustedPlatformAssemblies.End(); ) - { - SString fileName; - SString simpleName; - HRESULT pathResult = S_OK; - IF_FAIL_GO(pathResult = GetNextTPAPath(sTrustedPlatformAssemblies, i, /*dllOnly*/ true, fileName, simpleName)); - if (pathResult == S_FALSE) - { - break; - } - - if (simpleName.EqualsCaseInsensitive(sCoreLibSimpleName)) - { - sCoreLib = fileName; - found = true; - break; - } - } - - if (!found) - { - GO_WITH_HRESULT(HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)); - } + // For a single-file app with extracted contents (IncludeAllContentForSelfExtract), + // CoreCLR is statically linked into the host executable, so systemDirectory is the + // directory of the host executable. The extracted CoreLib lives in the bundle + // extraction directory rather than beside the host. Try to find it there. + sCoreLib.Set(Bundle::AppBundle->ExtractionPath()); + CombinePath(sCoreLib, sCoreLibName, sCoreLib); hr = AssemblyBinderCommon::GetAssembly(sCoreLib, TRUE /* fIsInTPA */, diff --git a/src/coreclr/hosts/corerun/corerun.cpp b/src/coreclr/hosts/corerun/corerun.cpp index d6032091a94adc..e5b7d2224cfa49 100644 --- a/src/coreclr/hosts/corerun/corerun.cpp +++ b/src/coreclr/hosts/corerun/corerun.cpp @@ -445,6 +445,14 @@ static int run(const configuration& config) { // Use the external assembly probe to load assemblies from the app assembly paths. use_external_assembly_probe = true; + } + else + { + tpa_list = std::move(app_assemblies_env); + } + + if (use_external_assembly_probe) + { if (!core_libs.empty()) { pal::string_utf8_t core_libs_utf8 = pal::convert_to_utf8(core_libs.c_str()); @@ -459,10 +467,6 @@ static int run(const configuration& config) ::strcpy(s_core_root_path, core_root_utf8.c_str()); } } - else - { - tpa_list = std::move(app_assemblies_env); - } { // Load hostpolicy if requested.