private static void OpenWithGameStudioMenuCommand_Callback(object sender, EventArgs e) { var dte = (DTE2)ServiceProvider.GetService(typeof(SDTE)); var solutionFile = dte.Solution?.FileName; // Is there any active solution? if (solutionFile == null) { return; } // Locate GameStudio var packageInfo = XenkoCommandsProxy.CurrentPackageInfo; if (packageInfo.LoadedVersion == null || packageInfo.SdkPath == null) { return; } var store = new NugetStore(packageInfo.StorePath); var mainExecutable = store.LocateMainExecutable(packageInfo.SdkPath); if (Process.Start(mainExecutable, $"\"{solutionFile}\"") == null) { throw new InvalidOperationException("Could not start GameStudio process"); } }
public async Task StartStudio(string argument) { if (argument == null) { throw new ArgumentNullException(nameof(argument)); } if (ActiveVersion == null) { return; } if (AutoCloseLauncher) { argument = $"/LauncherWindowHandle {WindowHandle} {argument}"; } MetricsClient metricsForEditorBefore120 = null; try { Dispatcher.Invoke(() => StartStudioCommand.IsEnabled = false); var packagePath = ActiveVersion.InstallPath; var mainExecutable = store.LocateMainExecutable(packagePath); // If version is older than 1.2.0, than we need to log the usage of older version var activeStoreVersion = ActiveVersion as XenkoStoreVersionViewModel; if (activeStoreVersion != null && activeStoreVersion.Version.Version < new Version(1, 2, 0, 0)) { metricsForEditorBefore120 = new MetricsClient(CommonApps.XenkoEditorAppId, versionOverride: activeStoreVersion.Version.ToString()); } Process.Start(mainExecutable, argument); } catch (Exception e) { var message = string.Format(Strings.ErrorStartingProcess, e.FormatSummary(true)); await ServiceProvider.Get <IDialogService>().MessageBox(message, MessageBoxButton.OK, MessageBoxImage.Error); } finally { metricsForEditorBefore120?.Dispose(); } await Task.Delay(5000); Dispatcher.Invoke(() => { StartStudioCommand.IsEnabled = ActiveVersion != null; //Save settings because launcher maybe have not been closed LauncherSettings.ActiveVersion = ActiveVersion != null ? ActiveVersion.Name : ""; LauncherSettings.Save(); }); }