From fcf1726b3bf1ef1298843ff42f50f9376c05a229 Mon Sep 17 00:00:00 2001 From: John Beisner Date: Tue, 16 May 2017 10:30:59 -0700 Subject: [PATCH] Minor code refactoring; fixed a test... Commit migrated from https://github.com/dotnet/core-setup/commit/ff4abe13839f6f5f3bdbc5e0e2fd0c0fc5aeeeb8 --- src/installer/corehost/cli/fxr/fx_muxer.cpp | 16 +++++++--------- .../GivenThatICareAboutMultilevelSDKLookup.cs | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/installer/corehost/cli/fxr/fx_muxer.cpp b/src/installer/corehost/cli/fxr/fx_muxer.cpp index f6e0a5e..4bea9107 100644 --- a/src/installer/corehost/cli/fxr/fx_muxer.cpp +++ b/src/installer/corehost/cli/fxr/fx_muxer.cpp @@ -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()) { diff --git a/src/installer/test/HostActivationTests/GivenThatICareAboutMultilevelSDKLookup.cs b/src/installer/test/HostActivationTests/GivenThatICareAboutMultilevelSDKLookup.cs index 0e91f24..306883b 100644 --- a/src/installer/test/HostActivationTests/GivenThatICareAboutMultilevelSDKLookup.cs +++ b/src/installer/test/HostActivationTests/GivenThatICareAboutMultilevelSDKLookup.cs @@ -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"); -- 2.7.4