Don't search global store when DOTNET_MULTILEVEL_LOOKUP is disabled (dotnet/core...
authorSteve Harter <steveharter@users.noreply.github.com>
Thu, 19 Oct 2017 21:18:55 +0000 (16:18 -0500)
committerGitHub <noreply@github.com>
Thu, 19 Oct 2017 21:18:55 +0000 (16:18 -0500)
The global store location is being searched when the DOTNET_MULTILEVEL_LOOKUP environment variable is zero (disabled). DOTNET_MULTILEVEL_LOOKUP controls whether the global locations are used when looking for the shared framework (C:\Program Files\dotnet\shared), and the change here is to also have DOTNET_MULTILEVEL_LOOKUP control whether the store global location (C:\Program Files\dotnet\store) is searched.

Commit migrated from https://github.com/dotnet/core-setup/commit/88da334986d5f560c98248c2cfff6e5816cdde7a

src/installer/corehost/cli/args.cpp
src/installer/corehost/cli/fxr/fx_muxer.cpp
src/installer/corehost/common/utils.cpp
src/installer/corehost/common/utils.h
src/installer/test/HostActivationTests/GivenThatICareAboutPortableAppActivation.cs

index 74a4fe3..b55ba1c 100644 (file)
@@ -49,7 +49,11 @@ void setup_shared_store_paths(const hostpolicy_init_t& init, const pal::string_t
     }
 
     // Global shared store dir
-    get_global_shared_store_dirs(&args->global_shared_stores, get_arch(), init.tfm);
+    bool multilevel_lookup = multilevel_lookup_enabled();
+    if (multilevel_lookup)
+    {
+        get_global_shared_store_dirs(&args->global_shared_stores, get_arch(), init.tfm);
+    }
 }
 
 bool parse_arguments(
index 939e23c..e687894 100644 (file)
 #include "error_codes.h"
 #include "deps_format.h"
 
-/**
- * Multilevel Lookup is enabled by default
- *  It can be disabled by setting DOTNET_MULTILEVEL_LOOKUP env var to a value that is not 1
- */
-bool multilevel_lookup_enabled()
-{
-    pal::string_t env_lookup;
-    bool multilevel_lookup = true;
-
-    if (pal::getenv(_X("DOTNET_MULTILEVEL_LOOKUP"), &env_lookup))
-    {
-        auto env_val = pal::xtoi(env_lookup.c_str());
-        multilevel_lookup = (env_val == 1);
-    }
-    return multilevel_lookup;
-}
-
 void get_all_fx_versions(
     host_mode_t mode,
     const pal::string_t& own_dir,
index f6deb77..7d40279 100644 (file)
@@ -303,3 +303,20 @@ bool get_global_shared_store_dirs(std::vector<pal::string_t>*  dirs, const pal::
     }
     return true;
 }
+
+/**
+* Multilevel Lookup is enabled by default
+*  It can be disabled by setting DOTNET_MULTILEVEL_LOOKUP env var to a value that is not 1
+*/
+bool multilevel_lookup_enabled()
+{
+    pal::string_t env_lookup;
+    bool multilevel_lookup = true;
+
+    if (pal::getenv(_X("DOTNET_MULTILEVEL_LOOKUP"), &env_lookup))
+    {
+        auto env_val = pal::xtoi(env_lookup.c_str());
+        multilevel_lookup = (env_val == 1);
+    }
+    return multilevel_lookup;
+}
index 22cd5f3..b50fbc2 100644 (file)
@@ -44,4 +44,5 @@ bool parse_known_args(
 bool skip_utf8_bom(pal::ifstream_t* stream);
 bool get_env_shared_store_dirs(std::vector<pal::string_t>* dirs, const pal::string_t& arch, const pal::string_t& tfm);
 bool get_global_shared_store_dirs(std::vector<pal::string_t>* dirs, const pal::string_t& arch, const pal::string_t& tfm);
+bool multilevel_lookup_enabled();
 #endif
index c262393..63d2be1 100644 (file)
@@ -147,6 +147,7 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.PortableApp
                     "--additionalprobingpath", additionalProbingPath,
                     appDll)
                 .EnvironmentVariable("COREHOST_TRACE", "1")
+                .EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
                 .CaptureStdErr()
                 .CaptureStdOut()
                 .Execute()