private static Version TryGetUnityVersionFromDll(XmlElement documentElement) { var referencePathElement = documentElement.ChildElements() .Where(a => a.Name == "ItemGroup").SelectMany(b => b.ChildElements()) .Where(c => c.Name == "Reference" && c.GetAttribute("Include").StartsWith("UnityEngine") || c.GetAttribute("Include").Equals("UnityEditor")) .SelectMany(d => d.ChildElements()) .FirstOrDefault(c => c.Name == "HintPath"); if (referencePathElement == null || string.IsNullOrEmpty(referencePathElement.InnerText)) { return(null); } var filePath = FileSystemPath.Parse(referencePathElement.InnerText); if (!filePath.IsAbsolute) // RIDER-21237 { return(null); } if (filePath.ExistsFile) { if (PlatformUtil.RuntimePlatform == PlatformUtil.Platform.Windows) { var exePath = filePath.Combine("../../../Unity.exe"); // Editor\Data\Managed\UnityEngine.dll if (!exePath.ExistsFile) { exePath = filePath.Combine("../../../../Unity.exe"); // Editor\Data\Managed\UnityEngine\UnityEngine.dll } if (exePath.ExistsFile) { return(new Version(new Version(FileVersionInfo.GetVersionInfo(exePath.FullPath).FileVersion).ToString(3))); } } else if (PlatformUtil.RuntimePlatform == PlatformUtil.Platform.MacOsX) { var infoPlistPath = filePath.Combine("../../Info.plist"); if (!infoPlistPath.ExistsFile) { infoPlistPath = filePath.Combine("../../../Info.plist"); } if (!infoPlistPath.ExistsFile) { return(null); } var fullVersion = UnityVersion.GetVersionFromInfoPlist(infoPlistPath); return(UnityVersion.Parse(fullVersion)); } } return(null); }