internal StrideVersionViewModel(LauncherViewModel launcher, NugetStore store, NugetLocalPackage localPackage, string packageId, int major, int minor) : base(launcher, store, localPackage) { PackageSimpleName = packageId.Replace(".GameStudio", string.Empty); Major = major; Minor = minor; SetAsActiveCommand = new AnonymousCommand(ServiceProvider, () => launcher.ActiveVersion = this); // Update status if the user changes whether to display beta versions. launcher.PropertyChanged += (s, e) => { if (e.PropertyName == nameof(LauncherViewModel.ShowBetaVersions)) { UpdateStatus(); } }; if (LocalPackage != null && InstallPath != null) { var libDirectory = Path.Combine(InstallPath, "lib"); var frameworks = Directory.EnumerateDirectories(libDirectory); foreach (var frameworkPath in frameworks) { var frameworkFolder = new DirectoryInfo(frameworkPath).Name; if (File.Exists(Path.Combine(frameworkPath, "Stride.GameStudio.exe")) || File.Exists(Path.Combine(frameworkPath, "Xenko.GameStudio.exe"))) { Frameworks.Add(frameworkFolder); } } if (Frameworks.Count > 0) { try { // If preferred framework exists in our list, select it var preferredFramework = LauncherSettings.PreferredFramework; if (Frameworks.Contains(preferredFramework)) { SelectedFramework = preferredFramework; } else { // Otherwise, try to find a framework of the same kind (.NET Core or .NET Framework) var nugetFramework = NuGetFramework.ParseFolder(preferredFramework); SelectedFramework = Frameworks.FirstOrDefault(x => NuGetFramework.ParseFolder(preferredFramework).Framework == nugetFramework.Framework) ?? Frameworks.First(); // otherwise fallback to first choice } } catch { SelectedFramework = Frameworks.First(); } } } }
protected void UpdateFrameworks() { Frameworks.Clear(); if (LocalPackage != null && InstallPath != null) { foreach (var toplevelFolder in new[] { "tools", "lib" }) { var libDirectory = Path.Combine(InstallPath, toplevelFolder); var frameworks = Directory.EnumerateDirectories(libDirectory); foreach (var frameworkPath in frameworks) { var frameworkFolder = new DirectoryInfo(frameworkPath).Name; if (File.Exists(Path.Combine(frameworkPath, "Stride.GameStudio.exe")) || File.Exists(Path.Combine(frameworkPath, "Xenko.GameStudio.exe"))) { Frameworks.Add(frameworkFolder); } } } if (Frameworks.Count > 0) { try { // If preferred framework exists in our list, select it var preferredFramework = LauncherSettings.PreferredFramework; if (Frameworks.Contains(preferredFramework)) { SelectedFramework = preferredFramework; } else { // Otherwise, try to find a framework of the same kind (.NET Core or .NET Framework) var nugetFramework = NuGetFramework.ParseFolder(preferredFramework); SelectedFramework = Frameworks.FirstOrDefault(x => NuGetFramework.ParseFolder(preferredFramework).Framework == nugetFramework.Framework) ?? Frameworks.First(); // otherwise fallback to first choice } } catch { SelectedFramework = Frameworks.First(); } } } }