private static bool RegenerateProjectUsingUBT(Lifetime lifetime, UnrealHost unrealHost, VirtualFileSystemPath uprojectFile, VirtualFileSystemPath pathToUnrealBuildToolBin, VirtualFileSystemPath engineRoot) { if (uprojectFile.IsNullOrEmpty()) { return(false); } bool isInstalledBuild = IsInstalledBuild(engineRoot); var pipeStreams = CreatePipeStreams(unrealHost, "[UBT]:"); var startInfo = CmdUtils.GetProcessStartInfo(pipeStreams, pathToUnrealBuildToolBin, pathToUnrealBuildToolBin.Directory, "-ProjectFiles", $"-project=\"{uprojectFile.FullPath}\"", "-game", isInstalledBuild ? "-rocket" : "-engine"); try { var result = CmdUtils.RunCommandWithLock(lifetime, startInfo, ourLogger) == 0; if (!result) { ourLogger.Warn($"[UnrealLink]: Failed refresh project files: calling {startInfo.Arguments}"); } return(result); } catch (ErrorLevelException errorLevelException) { ourLogger.Error(errorLevelException, $"[UnrealLink]: Failed refresh project files: calling {startInfo.Arguments}"); return(false); } }
private static InvokeChildProcess.PipeStreams CreatePipeStreams(UnrealHost unrealHost, string prefix) { return(InvokeChildProcess.PipeStreams.Custom((chunk, isErr, logger) => { unrealHost.myModel.RiderLinkInstallMessage(new InstallMessage(chunk, isErr ? ContentType.Error : ContentType.Normal)); logger.Info(prefix + chunk); })); }
public UnrealPluginDetector(Lifetime lifetime, ILogger logger, UnrealHost unrealHost, CppUE4SolutionDetector solutionDetector, ISolution solution) { myLifetime = lifetime; InstallInfoProperty = new Property <UnrealPluginInstallInfo>(myLifetime, "UnrealPlugin.InstallInfoNotification", null, true); myLogger = logger; myUnrealHost = unrealHost; mySolution = solution; mySolutionDetector = solutionDetector; mySolutionDetector.IsUE4Solution_Observable.Change.Advise_When(myLifetime, newValue => newValue == TriBool.True, isUESolution => { myUnrealVersion = new Version(4, mySolutionDetector.UE4Version, mySolutionDetector.UE4PatchVersion); var installInfo = new UnrealPluginInstallInfo(); var foundEnginePlugin = TryGetEnginePluginFromSolution(mySolution, installInfo); var uprojectLocations = mySolution.GetAllProjects().SelectMany(project => project.GetAllProjectFiles(projectFile => { var location = projectFile.Location; if (location == null || !location.ExistsFile) { return(false); } return(location.ExtensionNoDot == UPROJECT_FILE_FORMAT && location.NameWithoutExtension == project.Name); })).Select(file => file.Location).ToSet(); if (!foundEnginePlugin) { // All projects in the solution are bound to the same engine // So take first project and use it to find Unreal Engine foundEnginePlugin = TryGetEnginePluginFromUproject(uprojectLocations.FirstNotNull(), installInfo); } if (!foundEnginePlugin) { // We didn't find Engine plugins, let's gather data about Project plugins foreach (var uprojectLocation in uprojectLocations) { var projectPlugin = GetProjectPluginForUproject(uprojectLocation, installInfo); installInfo.ProjectPlugins.Add(projectPlugin); } } InstallInfoProperty.SetValue(installInfo); }); }
private static bool RegenerateProjectUsingBundledUVS(Lifetime lifetime, UnrealHost unrealHost, VirtualFileSystemPath uprojectFile, VirtualFileSystemPath engineRoot) { if (PlatformUtil.RuntimePlatform != PlatformUtil.Platform.Windows) { return(false); } var pathToUnrealVersionSelector = engineRoot / "Engine" / "Binaries" / "Win64" / "UnrealVersionSelector.exe"; return(RegenerateProjectUsingUVS(lifetime, unrealHost, uprojectFile, pathToUnrealVersionSelector)); }
public UnrealPluginInstaller(Lifetime lifetime, ILogger logger, UnrealPluginDetector pluginDetector, PluginPathsProvider pathsProvider, ISolution solution, ISettingsStore settingsStore, UnrealHost unrealHost, NotificationsModel notificationsModel, RiderBackgroundTaskHost backgroundTaskHost) { Lifetime = lifetime; myLogger = logger; myPathsProvider = pathsProvider; mySolution = solution; myUnrealHost = unrealHost; myNotificationsModel = notificationsModel; myBackgroundTaskHost = backgroundTaskHost; myBoundSettingsStore = settingsStore.BindToContextLive(Lifetime, ContextRange.Smart(solution.ToDataContext())); myPluginDetector = pluginDetector; myPluginDetector.InstallInfoProperty.Change.Advise_NewNotNull(Lifetime, installInfo => { mySolution.Locks.ExecuteOrQueueReadLockEx(Lifetime, "UnrealPluginInstaller.CheckAllProjectsIfAutoInstallEnabled", () => { HandleAutoUpdatePlugin(installInfo.New); }); }); BindToInstallationSettingChange(); BindToNotificationFixAction(); }
private static bool RegenerateProjectUsingUVS(Lifetime lifetime, UnrealHost unrealHost, VirtualFileSystemPath uprojectFile, VirtualFileSystemPath pathToUnrealVersionSelector) { if (!uprojectFile.IsValidAndExistFile()) { return(false); } if (!pathToUnrealVersionSelector.ExistsFile) { ourLogger.Info($"[UnrealLink]: {pathToUnrealVersionSelector} is not available"); return(false); } var pipeStreams = CreatePipeStreams(unrealHost, "[UVS]:"); var startInfo = CmdUtils.GetProcessStartInfo(pipeStreams, pathToUnrealVersionSelector, pathToUnrealVersionSelector.Directory, "-projectFiles", $"\"{uprojectFile}\""); try { var result = CmdUtils.RunCommandWithLock(lifetime, startInfo, ourLogger) == 0; if (!result) { ourLogger.Warn( $"[UnrealLink]: Failed refresh project files: calling {pathToUnrealVersionSelector} {startInfo.Arguments}"); } return(result); } catch (ErrorLevelException errorLevelException) { ourLogger.Error(errorLevelException, $"[UnrealLink]: Failed refresh project files: calling {pathToUnrealVersionSelector} {startInfo.Arguments}"); return(false); } }
private static void RegenerateProjectFiles(Lifetime lifetime, ISolution solution, UnrealHost unrealHost, VirtualFileSystemPath engineRoot, VirtualFileSystemPath uprojectFile) { void LogFailedRefreshProjectFiles() { unrealHost.myModel.RiderLinkInstallMessage(new InstallMessage("Failed to refresh project files", ContentType.Normal)); unrealHost.myModel.RiderLinkInstallMessage( new InstallMessage("RiderLink will not be visible in solution explorer", ContentType.Normal)); unrealHost.myModel.RiderLinkInstallMessage(new InstallMessage( "Need to refresh project files in Unreal Editor or in File Explorer with context action for .uproject file 'Refresh Project files'", ContentType.Normal)); } if (!engineRoot.IsValidAndExistDirectory()) { ourLogger.Warn($"[UnrealLink]: Couldn't find Unreal Engine root"); LogFailedRefreshProjectFiles(); return; } var pathToUnrealBuildToolBin = CppUE4FolderFinder.GetAbsolutePathToUnrealBuildToolBin(engineRoot); // 1. If project is under engine root, use GenerateProjectFiles.{extension} first if (GenerateProjectFilesCmd(lifetime, solution, unrealHost, uprojectFile, engineRoot)) { return; } // 2. If it's a standalone project, use UnrealVersionSelector // The same way "Generate project files" from context menu of .uproject works if (RegenerateProjectUsingBundledUVS(lifetime, unrealHost, uprojectFile, engineRoot)) { return; } if (RegenerateProjectUsingSystemUVS(lifetime, solution, unrealHost, uprojectFile)) { return; } // 3. If UVS is missing or have failed, fallback to UnrealBuildTool if (RegenerateProjectUsingUBT(lifetime, unrealHost, uprojectFile, pathToUnrealBuildToolBin, engineRoot)) { return; } ourLogger.Warn("[UnrealLink]: Couldn't refresh project files"); LogFailedRefreshProjectFiles(); }
private static bool RegenerateProjectUsingSystemUVS(Lifetime lifetime, ISolution solution, UnrealHost unrealHost, VirtualFileSystemPath uprojectFile) { if (PlatformUtil.RuntimePlatform != PlatformUtil.Platform.Windows || uprojectFile.IsNullOrEmpty()) { return(false); } var programFiles = Environment.GetEnvironmentVariable("ProgramFiles(x86)"); if (programFiles.IsNullOrEmpty()) { return(false); } var programFilesPath = VirtualFileSystemPath.Parse(programFiles, solution.GetInteractionContext()); if (!programFilesPath.ExistsDirectory) { return(false); } var pathToUnrealVersionSelector = programFilesPath / "Epic Games" / "Launcher" / "Engine" / "Binaries" / "Win64" / "UnrealVersionSelector.exe"; return(RegenerateProjectUsingUVS(lifetime, unrealHost, uprojectFile, pathToUnrealVersionSelector)); }
private static bool GenerateProjectFilesCmd(Lifetime lifetime, ISolution solution, UnrealHost unrealHost, VirtualFileSystemPath uprojectFile, VirtualFileSystemPath engineRoot) { // Invalid uproject file means we couldn't get uproject file from solution detector and the project might be // under Engine source var invalidUprojectFile = !uprojectFile.IsValidAndExistFile(); var isProjectUnderEngine = uprojectFile.StartsWith(engineRoot) || invalidUprojectFile; if (!isProjectUnderEngine) { ourLogger.Info($"[UnrealLink]: {solution.SolutionFilePath} is not in {engineRoot} "); return(false); } var generateProjectFilesCmd = engineRoot / $"GenerateProjectFiles.{CmdUtils.GetPlatformCmdExtension()}"; if (!generateProjectFilesCmd.ExistsFile) { ourLogger.Info($"[UnrealLink]: {generateProjectFilesCmd} is not available"); return(false); } var pipeStreams = CreatePipeStreams(unrealHost, "[GenerateProjectFiles]:"); var startInfo = CmdUtils.GetProcessStartInfo(pipeStreams, generateProjectFilesCmd, generateProjectFilesCmd.Directory); ourLogger.Info($"[UnrealLink]: Regenerating project files: {startInfo.Arguments}"); try { var result = CmdUtils.RunCommandWithLock(lifetime, startInfo, ourLogger) == 0; if (!result) { ourLogger.Warn($"[UnrealLink]: Failed refresh project files, calling {generateProjectFilesCmd} went wrong"); } return(result); } catch (ErrorLevelException errorLevelException) { ourLogger.Error(errorLevelException, $"[UnrealLink]: Failed refresh project files, calling {generateProjectFilesCmd} went wrong"); return(false); } }