// Note: this method cannot be generalized past V4, because (a) it has // specific code for detecting .NET 4.5 and (b) we don't know what // microsoft will do in the future private static void AppendDotNetFourFrameworkVersions(List<RuntimeFramework> frameworks, RegistryKey versionKey) { foreach (Profile profile in new Profile[] { Profile.Full, Profile.Client }) { var profileKey = versionKey.OpenSubKey(profile.ToString()); if (profileKey == null) continue; if (CheckInstallDword(profileKey)) { var framework = new RuntimeFramework(RuntimeType.Net, new Version(4, 0), profile); framework.Profile = profile; frameworks.Add(framework); var release = (int)profileKey.GetValue("Release", 0); if (release > 0) { framework = new RuntimeFramework(RuntimeType.Net, new Version(4, 5)); frameworks.Add(framework); } return; //If full profile found, return and don't check for client profile } } }
private static void AppendMonoFramework(List<RuntimeFramework> frameworks, string monoPrefix, string version) { if (monoPrefix != null) { string displayFmt = version != null ? "Mono " + version + " - {0} Profile" : "Mono {0} Profile"; if (File.Exists(Path.Combine(monoPrefix, "lib/mono/1.0/mscorlib.dll"))) { RuntimeFramework framework = new RuntimeFramework(RuntimeType.Mono, new Version(1, 1, 4322)); framework.DisplayName = string.Format(displayFmt, "1.0"); frameworks.Add(framework); } if (File.Exists(Path.Combine(monoPrefix, "lib/mono/2.0/mscorlib.dll"))) { RuntimeFramework framework = new RuntimeFramework(RuntimeType.Mono, new Version(2, 0, 50727)); framework.DisplayName = string.Format(displayFmt, "2.0"); frameworks.Add(framework); } if (Directory.Exists(Path.Combine(monoPrefix, "lib/mono/3.5"))) { RuntimeFramework framework = new RuntimeFramework(RuntimeType.Mono, new Version(2, 0, 50727)); framework.FrameworkVersion = new Version(3,5); framework.DisplayName = string.Format(displayFmt, "3.5"); frameworks.Add(framework); } if (File.Exists(Path.Combine(monoPrefix, "lib/mono/4.0/mscorlib.dll"))) { RuntimeFramework framework = new RuntimeFramework(RuntimeType.Mono, new Version(4, 0, 30319)); framework.DisplayName = string.Format(displayFmt, "4.0"); frameworks.Add(framework); } if (File.Exists(Path.Combine(monoPrefix, "lib/mono/4.5/mscorlib.dll"))) { RuntimeFramework framework = new RuntimeFramework(RuntimeType.Mono, new Version(4, 0, 30319)); framework.FrameworkVersion = new Version(4,5); framework.DisplayName = string.Format(displayFmt, "4.5"); frameworks.Add(framework); } } }
/// <summary> /// Returns true if the current framework matches the /// one supplied as an argument. Two frameworks match /// if their runtime types are the same or either one /// is RuntimeType.Any and all specified version components /// are equal. Negative (i.e. unspecified) version /// components are ignored. /// </summary> /// <param name="target">The RuntimeFramework to be matched.</param> /// <returns><c>true</c> on match, otherwise <c>false</c></returns> public bool Supports(RuntimeFramework target) { if (this.Runtime != RuntimeType.Any && target.Runtime != RuntimeType.Any && this.Runtime != target.Runtime) return false; if (this.AllowAnyVersion || target.AllowAnyVersion) return true; return VersionsMatch(this.ClrVersion, target.ClrVersion) && this.FrameworkVersion.Major >= target.FrameworkVersion.Major && this.FrameworkVersion.Minor >= target.FrameworkVersion.Minor; }
/// <summary> /// Returns the best available framework that matches a target framework. /// If the target framework has a build number specified, then an exact /// match is needed. Otherwise, the matching framework with the highest /// build number is used. /// </summary> /// <param name="target"></param> /// <returns></returns> public static RuntimeFramework GetBestAvailableFramework(RuntimeFramework target) { RuntimeFramework result = target; if (target.ClrVersion.Build < 0) { foreach (RuntimeFramework framework in AvailableFrameworks) if (framework.Supports(target) && framework.ClrVersion.Build > result.ClrVersion.Build) { result = framework; } } return result; }
// Note: this method cannot be generalized past V4, because (a) it has // specific code for detecting .NET 4.5 and (b) we don't know what // microsoft will do in the future private static void AppendDotNetFourFrameworkVersions(List<RuntimeFramework> frameworks, RegistryKey versionKey) { foreach (string profile in new string[] { "Full", "Client" }) { var profileKey = versionKey.OpenSubKey(profile); if (profileKey == null) continue; if (CheckInstallDword(profileKey)) { var framework = new RuntimeFramework(RuntimeType.Net, new Version(4, 0)); framework.DisplayName += " - " + profile; frameworks.Add(framework); var release = (int)profileKey.GetValue("Release", 0); if (release > 0) { framework = new RuntimeFramework(RuntimeType.Net, new Version(4, 5)); framework.DisplayName += " - " + profile; frameworks.Add(framework); } } } }
public bool CanLoad(RuntimeFramework requested) { return(FrameworkVersion >= requested.FrameworkVersion); }