Пример #1
0
        private void RegenerateProjectFiles(FileSystemPath uprojectFilePath)
        {
            if (uprojectFilePath == null || uprojectFilePath.IsEmpty)
            {
                return;
            }
            // {UnrealEngineRoot}/Engine/Binaries/DotNET/UnrealBuildTool.exe  -projectfiles {uprojectFilePath} -game -engine
            var engineRoot = UnrealEngineFolderFinder.FindUnrealEngineRoot(uprojectFilePath);
            var pathToUnrealBuildToolBin = UnrealEngineFolderFinder.GetAbsolutePathToUnrealBuildToolBin(engineRoot);
            var commandLine = new CommandLineBuilderJet()
                              .AppendSwitch("-ProjectFiles")
                              .AppendFileName(uprojectFilePath)
                              .AppendSwitch("-game")
                              .AppendSwitch("-engine");

            try
            {
                ErrorLevelException.ThrowIfNonZero(InvokeChildProcess.InvokeChildProcessIntoLogger(
                                                       pathToUnrealBuildToolBin,
                                                       commandLine,
                                                       LoggingLevel.INFO,
                                                       TimeSpan.FromMinutes(10),
                                                       InvokeChildProcess.TreatStderr.AsOutput,
                                                       pathToUnrealBuildToolBin.Directory
                                                       ));
            }
            catch (ErrorLevelException)
            {
                // TODO: handle properly
            }
        }
Пример #2
0
        private bool GenerateProjectFilesCmd(FileSystemPath engineRoot)
        {
            var isProjectUnderEngine = mySolution.SolutionFilePath.Directory == engineRoot;

            if (!isProjectUnderEngine)
            {
                myLogger.Info($"[UnrealLink]: {mySolution.SolutionFilePath} is not in {engineRoot} ");
                return(false);
            }

            var generateProjectFilesCmd = engineRoot / $"GenerateProjectFiles.{GetPlatformCmdExtension()}";

            if (!generateProjectFilesCmd.ExistsFile)
            {
                myLogger.Info($"[UnrealLink]: {generateProjectFilesCmd} is not available");
                return(false);
            }

            try
            {
                var command     = GetPlatformCommand(generateProjectFilesCmd);
                var commandLine = GetPlatformCommandLine(generateProjectFilesCmd);

                lock (HACK_getMutexForUBT())
                {
                    myLogger.Info($"[UnrealLink]: Regenerating project files: {commandLine}");

                    ErrorLevelException.ThrowIfNonZero(InvokeChildProcess.InvokeChildProcessIntoLogger(command,
                                                                                                       commandLine,
                                                                                                       LoggingLevel.INFO,
                                                                                                       TimeSpan.FromMinutes(1),
                                                                                                       InvokeChildProcess.TreatStderr.AsOutput,
                                                                                                       generateProjectFilesCmd.Directory
                                                                                                       ));
                }
            }
            catch (ErrorLevelException errorLevelException)
            {
                myLogger.Error(errorLevelException,
                               $"[UnrealLink]: Failed refresh project files, calling {generateProjectFilesCmd} went wrong");
                return(false);
            }

            return(true);
        }
Пример #3
0
        private bool RegenerateProjectUsingUVS(FileSystemPath uprojectFilePath, FileSystemPath engineRoot)
        {
            if (PlatformUtil.RuntimePlatform != PlatformUtil.Platform.Windows)
            {
                return(false);
            }

            var pathToUnrealVersionSelector =
                engineRoot / "Engine" / "Binaries" / "Win64" / "UnrealVersionSelector.exe";

            if (!pathToUnrealVersionSelector.ExistsFile)
            {
                myLogger.Info($"[UnrealLink]: {pathToUnrealVersionSelector} is not available");
                return(false);
            }

            var commandLine =
                GetPlatformCommandLine(pathToUnrealVersionSelector, "/projectFiles", $"\"{uprojectFilePath}\"");

            try
            {
                lock (HACK_getMutexForUBT())
                {
                    myLogger.Info($"[UnrealLink]: Regenerating project files: {commandLine}");
                    ErrorLevelException.ThrowIfNonZero(InvokeChildProcess.InvokeChildProcessIntoLogger(
                                                           BatchUtils.GetPathToCmd(),
                                                           commandLine,
                                                           LoggingLevel.INFO,
                                                           TimeSpan.FromMinutes(1),
                                                           InvokeChildProcess.TreatStderr.AsOutput,
                                                           pathToUnrealVersionSelector.Directory
                                                           ));
                }
            }
            catch (ErrorLevelException errorLevelException)
            {
                myLogger.Error(errorLevelException,
                               $"[UnrealLink]: Failed refresh project files: calling {pathToUnrealVersionSelector} {commandLine}");
                return(false);
            }

            return(true);
        }
Пример #4
0
        private bool RegenerateProjectUsingUBT(FileSystemPath uprojectFilePath, FileSystemPath pathToUnrealBuildToolBin,
                                               FileSystemPath engineRoot)
        {
            bool isInstalledBuild = IsInstalledBuild(engineRoot);

            var commandLine = new CommandLineBuilderJet()
                              .AppendSwitch("-ProjectFiles")
                              .AppendSwitch($"-project=\"{uprojectFilePath.FullPath}\"")
                              .AppendSwitch("-game");

            commandLine.AppendSwitch(isInstalledBuild ? "-rocket" : "-engine");

            try
            {
                lock (HACK_getMutexForUBT())
                {
                    myLogger.Info($"[UnrealLink]: Regenerating project files: {commandLine}");
                    ErrorLevelException.ThrowIfNonZero(InvokeChildProcess.InvokeChildProcessIntoLogger(
                                                           pathToUnrealBuildToolBin,
                                                           commandLine,
                                                           LoggingLevel.INFO,
                                                           TimeSpan.FromMinutes(1),
                                                           InvokeChildProcess.TreatStderr.AsOutput,
                                                           pathToUnrealBuildToolBin.Directory
                                                           ));
                }
            }
            catch (Exception errorLevelException)
            {
                myLogger.Error(errorLevelException,
                               $"[UnrealLink]: Failed refresh project files: calling {commandLine}");
                return(false);
            }

            return(true);
        }