in Clients/Xamarin.Interactive.Client.Mac/SystemInformation/VisualStudioForMacComponent.cs [136:208]
void Locate ()
{
var bundlePath = NSWorkspace.SharedWorkspace.AbsolutePathForAppBundle (bundleId);
if (bundlePath == null)
return;
Bundle = NSBundle.FromPath (bundlePath);
if (Bundle == null)
return;
AppPath = Bundle.BundlePath;
if (!Bundle.InfoDictionary.TryGetValue (
new NSString ("CFBundleName"), out var nameOut) || nameOut == null)
return;
Name = nameOut.ToString ();
if (!Bundle.InfoDictionary.TryGetValue (
new NSString ("CFBundleVersion"), out var versionOut) || versionOut == null)
return;
Version = versionOut.ToString ();
System.Version.TryParse (Version, out var sysVersion);
var updateinfoPath = new FilePath (bundlePath).Combine ("Contents", "MacOS", "updateinfo");
if (updateinfoPath.FileExists) {
var updateinfo = XamarinComponent.ReadUpdateinfoFile (updateinfoPath);
if (updateinfo != null)
Version += $" ({updateinfo})";
}
var libraryUrl = NSFileManager.DefaultManager.GetUrl (
NSSearchPathDirectory.LibraryDirectory,
NSSearchPathDomain.User,
null,
false,
out var error);
if (error != null)
throw new NSErrorException (error);
if (libraryUrl == null)
throw new DirectoryNotFoundException ("unable to locate user Library directory");
if (sysVersion == null)
return;
var isVsm = bundleId == VSMacBundleId;
// Do not entertain any of the very first VSM preview releases
if (isVsm && sysVersion < firstStableVSMVersion)
return;
foreach (var compatVersion in new [] {
$"{sysVersion.Major}.{sysVersion.Minor}",
$"{sysVersion.Major}.0" }) {
if (isVsm)
PreferencesDirectory = new FilePath (libraryUrl.Path).Combine (
"Preferences",
"VisualStudio",
compatVersion);
else
PreferencesDirectory = new FilePath (libraryUrl.Path).Combine (
"Preferences",
$"XamarinStudio-{compatVersion}");
if (PreferencesDirectory.DirectoryExists)
break;
}
IsInstalled = AppPath.DirectoryExists && !string.IsNullOrEmpty (Version);
}