Minor code refactoring; fixed a test...
authorJohn Beisner <jbeisner@microsoft.com>
Tue, 16 May 2017 17:30:59 +0000 (10:30 -0700)
committerJohn Beisner <jbeisner@microsoft.com>
Fri, 19 May 2017 20:29:47 +0000 (13:29 -0700)
Commit migrated from https://github.com/dotnet/core-setup/commit/f7bba535cd55f8bcf464eddf5d0f5c9ea7802cff

src/installer/corehost/cli/fxr/fx_muxer.cpp
src/installer/test/HostActivationTests/GivenThatICareAboutMultilevelSDKLookup.cs

index f6e0a5e..4bea910 100644 (file)
@@ -589,10 +589,10 @@ pal::string_t resolve_sdk_version(pal::string_t sdk_path)
     trace::verbose(_X("Checking if resolved SDK dir [%s] exists"), sdk_path.c_str());
     if (pal::directory_exists(sdk_path))
     {
-        retval = sdk_path;
+        retval = max_ver_str;
     }
 
-    trace::verbose(_X("Resolved SDK dir is [%s]"), retval.c_str());
+    trace::verbose(_X("Resolved SDK dir is [%s]"), sdk_path.c_str());
     return retval;
 }
 
@@ -661,25 +661,23 @@ bool fx_muxer_t::resolve_sdk_dotnet_path(const pal::string_t& own_dir, const pal
 
     pal::string_t retval;
     bool cli_version_specified = false;
-    bool cli_version_found = false;
     pal::string_t cli_version;
 
     for (pal::string_t dir : hive_dir)
     {
         trace::verbose(_X("Searching SDK directory in [%s]"), dir.c_str());
+        pal::string_t sdk_path = dir;
+        append_path(&sdk_path, _X("sdk"));
         if (!global.empty())
         {
             cli_version = resolve_cli_version(global);
             if (!cli_version.empty())
             {
                 cli_version_specified = true;
-                pal::string_t sdk_path = dir;
-                append_path(&sdk_path, _X("sdk"));
                 append_path(&sdk_path, cli_version.c_str());
 
                 if (pal::directory_exists(sdk_path))
                 {
-                    cli_version_found = true;
                     trace::verbose(_X("CLI directory [%s] from global.json exists"), sdk_path.c_str());
                     retval = sdk_path;
                 }
@@ -691,9 +689,9 @@ bool fx_muxer_t::resolve_sdk_dotnet_path(const pal::string_t& own_dir, const pal
         }
         if (retval.empty() && !cli_version_specified)
         {
-            pal::string_t sdk_path = dir;
-            append_path(&sdk_path, _X("sdk"));
-            retval = resolve_sdk_version(sdk_path);
+            cli_version = resolve_sdk_version(sdk_path);
+            append_path(&sdk_path, cli_version.c_str());
+            retval = sdk_path;
         }
         if (!retval.empty())
         {
index 0e91f24..306883b 100644 (file)
@@ -198,7 +198,7 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.MultilevelSDKLookup
                 .Should()
                 .Fail()
                 .And
-                .HaveStdErrContaining("global.json] doesn't exist; install specified SDK version [9999.0.0-global-dummy]");
+                .HaveStdErrContaining("global.json] not found; install specified SDK version");
 
             // Add specified CLI version
             AddAvailableSdkVersions(_exeSdkBaseDir, "9999.0.0-global-dummy");