Update the host runtime version ordering SOS uses (#1753)
authorMike McLaughlin <mikem@microsoft.com>
Fri, 20 Nov 2020 00:41:50 +0000 (16:41 -0800)
committerGitHub <noreply@github.com>
Fri, 20 Nov 2020 00:41:50 +0000 (16:41 -0800)
src/SOS/Strike/hostcoreclr.cpp

index 3707184c0f0f6f5de9db0e6ff328dca265a0488e..a6f118f7b8e7248a7399eb7d0230e026316a3987 100644 (file)
@@ -375,39 +375,34 @@ static HRESULT GetHostRuntime(std::string& coreClrPath, std::string& hostRuntime
         }
         hostRuntimeDirectory.append(DIRECTORY_SEPARATOR_STR_A);
 
-        // First attempt find the highest LTS version. We want to start with the LTSs
-        // and only use the higher versions if it isn't installed.
-        if (!FindDotNetVersion(3, 1, hostRuntimeDirectory))
+        // Start with the latest released version and then the LTS's.
+        if (!FindDotNetVersion(5, 0, hostRuntimeDirectory))
         {
-            // Find highest 2.1 LTS version
-            if (!FindDotNetVersion(2, 1, hostRuntimeDirectory))
+            // Find highest 3.1.x LTS version
+            if (!FindDotNetVersion(3, 1, hostRuntimeDirectory))
             {
-                // Find highest 3.0.x version
-                if (!FindDotNetVersion(3, 0, hostRuntimeDirectory))
+                // Find highest 2.1.x LTS version
+                if (!FindDotNetVersion(2, 1, hostRuntimeDirectory))
                 {
-                    // Find highest 2.2.x version
-                    if (!FindDotNetVersion(2, 2, hostRuntimeDirectory))
+                    // Find highest 6.0.x version
+                    if (!FindDotNetVersion(6, 0, hostRuntimeDirectory))
                     {
-                        // Find highest 5.0.x version
-                        if (!FindDotNetVersion(5, 0, hostRuntimeDirectory))
+                        HRESULT hr = CheckEEDll();
+                        if (FAILED(hr)) {
+                            return hr;
+                        }
+                        // Don't use the desktop runtime to host
+                        if (g_pRuntime->GetRuntimeConfiguration() == IRuntime::WindowsDesktop)
+                        {
+                            return E_FAIL;
+                        }
+                        // If an installed runtime can not be found, use the target coreclr version
+                        LPCSTR runtimeDirectory = g_pRuntime->GetRuntimeDirectory();
+                        if (runtimeDirectory == nullptr)
                         {
-                            HRESULT hr = CheckEEDll();
-                            if (FAILED(hr)) {
-                                return hr;
-                            }
-                            // Don't use the desktop runtime to host
-                            if (g_pRuntime->GetRuntimeConfiguration() == IRuntime::WindowsDesktop)
-                            {
-                                return E_FAIL;
-                            }
-                            // If an installed runtime can not be found, use the target coreclr version
-                            LPCSTR runtimeDirectory = g_pRuntime->GetRuntimeDirectory();
-                            if (runtimeDirectory == nullptr)
-                            {
-                                return E_FAIL;
-                            }
-                            hostRuntimeDirectory = runtimeDirectory;
+                            return E_FAIL;
                         }
+                        hostRuntimeDirectory = runtimeDirectory;
                     }
                 }
             }