|
6 | 6 | using System.IO;
|
7 | 7 | using System.Linq;
|
8 | 8 | using System.Runtime.InteropServices;
|
| 9 | +using System.Text.Json; |
9 | 10 | using Microsoft.DotNet.Tools.Uninstall.Shared.BundleInfo;
|
10 | 11 | using Microsoft.DotNet.Tools.Uninstall.Shared.BundleInfo.Versioning;
|
11 | 12 | using Microsoft.DotNet.Tools.Uninstall.Shared.Configs;
|
@@ -46,12 +47,22 @@ public virtual IEnumerable<Bundle> GetAllInstalledBundles()
|
46 | 47 | return [..sdks, ..runtimes];
|
47 | 48 | }
|
48 | 49 |
|
49 |
| - private static bool IsMacx64Installation(string sdkVersionPath) |
| 50 | + private static bool IsMacx64Installation(string bundlePath, bool isSdk) |
50 | 51 | {
|
51 | 52 | try
|
52 | 53 | {
|
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 | + } |
55 | 66 | }
|
56 | 67 | catch
|
57 | 68 | {
|
@@ -89,7 +100,7 @@ private static IEnumerable<Bundle> GetInstalledBundles<TBundleVersion>(params st
|
89 | 100 | .Select(dirInfo =>
|
90 | 101 | {
|
91 | 102 | 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; |
93 | 104 | return (Success: success, Version: version, Path: dirInfo.FullName, Arch: arch);
|
94 | 105 | })
|
95 | 106 | .Where(tuple => tuple.Success)
|
|
0 commit comments