Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/dotnet-core-uninstall/MacOs/FileSystemExplorer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text.Json;
using Microsoft.DotNet.Tools.Uninstall.Shared.BundleInfo;
using Microsoft.DotNet.Tools.Uninstall.Shared.BundleInfo.Versioning;
using Microsoft.DotNet.Tools.Uninstall.Shared.Configs;
Expand Down Expand Up @@ -46,12 +47,22 @@ public virtual IEnumerable<Bundle> GetAllInstalledBundles()
return [..sdks, ..runtimes];
}

private static bool IsMacx64Installation(string sdkVersionPath)
private static bool IsMacx64Installation(string bundlePath, bool isSdk)
{
try
{
var rids = File.ReadAllText(Path.Combine(sdkVersionPath, "NETCoreSdkRuntimeIdentifierChain.txt"));
return !rids.Contains("osx-arm64");
if (isSdk)
{
var rids = File.ReadAllText(Path.Combine(bundlePath, "NETCoreSdkRuntimeIdentifierChain.txt"));
return !rids.Contains("osx-arm64");
}
else
{
var depsJsonFile = Directory.EnumerateFiles(bundlePath, "Microsoft.*.deps.json", SearchOption.TopDirectoryOnly).FirstOrDefault();
var targets = JsonSerializer.Deserialize<Dictionary<string, object>>(File.ReadAllText(depsJsonFile));
var runtimeTarget = (JsonElement)targets["runtimeTarget"];
return !runtimeTarget.GetProperty("name").ToString().Contains("osx-arm64");
}
}
catch
{
Expand Down Expand Up @@ -89,7 +100,7 @@ private static IEnumerable<Bundle> GetInstalledBundles<TBundleVersion>(params st
.Select(dirInfo =>
{
var success = BundleVersion.TryFromInput<TBundleVersion>(dirInfo.Name, out var version);
var arch = IsMacx64Installation(dirInfo.FullName) ? BundleArch.X64 : BundleArch.Arm64;
var arch = IsMacx64Installation(dirInfo.FullName, version is SdkVersion) ? BundleArch.X64 : BundleArch.Arm64;
return (Success: success, Version: version, Path: dirInfo.FullName, Arch: arch);
})
.Where(tuple => tuple.Success)
Expand Down