Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6c70385

Browse files
committed
Identify macOS runtimes correctly
1 parent 802fef7 commit 6c70385

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

src/dotnet-core-uninstall/MacOs/FileSystemExplorer.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.IO;
77
using System.Linq;
88
using System.Runtime.InteropServices;
9+
using System.Text.Json;
910
using Microsoft.DotNet.Tools.Uninstall.Shared.BundleInfo;
1011
using Microsoft.DotNet.Tools.Uninstall.Shared.BundleInfo.Versioning;
1112
using Microsoft.DotNet.Tools.Uninstall.Shared.Configs;
@@ -46,12 +47,22 @@ public virtual IEnumerable<Bundle> GetAllInstalledBundles()
4647
return [..sdks, ..runtimes];
4748
}
4849

49-
private static bool IsMacx64Installation(string sdkVersionPath)
50+
private static bool IsMacx64Installation(string bundlePath, bool isSdk)
5051
{
5152
try
5253
{
53-
var rids = File.ReadAllText(Path.Combine(sdkVersionPath, "NETCoreSdkRuntimeIdentifierChain.txt"));
54-
return !rids.Contains("osx-arm64");
54+
if (isSdk)
55+
{
56+
var rids = File.ReadAllText(Path.Combine(bundlePath, "NETCoreSdkRuntimeIdentifierChain.txt"));
57+
return !rids.Contains("osx-arm64");
58+
}
59+
else
60+
{
61+
var depsJsonFile = Directory.EnumerateFiles(bundlePath, "Microsoft.*.deps.json", SearchOption.TopDirectoryOnly).FirstOrDefault();
62+
var targets = JsonSerializer.Deserialize<Dictionary<string, object>>(File.ReadAllText(depsJsonFile));
63+
var runtimeTarget = (JsonElement)targets["runtimeTarget"];
64+
return !runtimeTarget.GetProperty("name").ToString().Contains("osx-arm64");
65+
}
5566
}
5667
catch
5768
{
@@ -89,7 +100,7 @@ private static IEnumerable<Bundle> GetInstalledBundles<TBundleVersion>(params st
89100
.Select(dirInfo =>
90101
{
91102
var success = BundleVersion.TryFromInput<TBundleVersion>(dirInfo.Name, out var version);
92-
var arch = IsMacx64Installation(dirInfo.FullName) ? BundleArch.X64 : BundleArch.Arm64;
103+
var arch = IsMacx64Installation(dirInfo.FullName, version is SdkVersion) ? BundleArch.X64 : BundleArch.Arm64;
93104
return (Success: success, Version: version, Path: dirInfo.FullName, Arch: arch);
94105
})
95106
.Where(tuple => tuple.Success)

src/dotnet-core-uninstall/Windows/RegistryQuery.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ internal static bool IsNetCoreBundle(string displayName, string displayVersion,
8282
(displayName.IndexOf("Dotnet Shared Framework for Windows Desktop", StringComparison.OrdinalIgnoreCase) >= 0) ||
8383
(displayName.IndexOf("Windows Desktop Runtime", StringComparison.OrdinalIgnoreCase) >= 0)) &&
8484
(!String.IsNullOrEmpty(uninstallString)) &&
85-
(uninstallString.IndexOf(".exe", StringComparison.OrdinalIgnoreCase) >= 0) &&
85+
// (uninstallString.IndexOf(".exe", StringComparison.OrdinalIgnoreCase) >= 0) &&
8686
(uninstallString.IndexOf("msiexec", StringComparison.OrdinalIgnoreCase) < 0) &&
87-
(!String.IsNullOrEmpty(displayVersion)) &&
88-
(!String.IsNullOrEmpty(bundleVersion));
87+
(!String.IsNullOrEmpty(displayVersion)) && true;
88+
// (!String.IsNullOrEmpty(bundleVersion));
8989
}
9090

9191
private static Bundle WrapRegistryKey(RegistryKey registryKey)

0 commit comments

Comments
 (0)