internal static bool CompileGeneratedCode() { CodeGeneratorSettings settings = new CodeGeneratorSettings(); string slnPath = Path.GetFullPath(Path.Combine(settings.GetManagedModulesDir(), "UnrealEngine.sln")); string projPath = Path.GetFullPath(Path.Combine(settings.GetManagedModulesDir(), "UnrealEngine.csproj")); return(CompileCode(slnPath, projPath)); }
private static void CompileGeneratedCode() { CodeGeneratorSettings _settings = new CodeGeneratorSettings(); string _slnPath = Path.GetFullPath(Path.Combine(_settings.GetManagedModulesDir(), "UnrealEngine.sln")); string _projPath = Path.GetFullPath(Path.Combine(_settings.GetManagedModulesDir(), "UnrealEngine.csproj")); string _pluginInstallerPath = Path.GetFullPath(Path.Combine(_settings.GetManagedModulesDir(), "../", "../", "../", "Binaries", "Managed", "PluginInstaller", "PluginInstaller.exe")); if (!File.Exists(_slnPath)) { Log(ELogVerbosity.Error, "Can't Compile: The Solution " + _slnPath + " doesn't exist"); return; } if (!File.Exists(_projPath)) { Log(ELogVerbosity.Error, "Can't Compile: The Project " + _projPath + " doesn't exist"); return; } if (!File.Exists(_pluginInstallerPath)) { Log(ELogVerbosity.Error, "Can't Compile: Can't Find Plugin Installer At Path: " + _pluginInstallerPath); return; } Log(ELogVerbosity.Log, "Attempting To Build Generated Solution at " + _slnPath); int timeout = 60000; bool built = false; int _exitCode = 0; string _arguments = "buildcustomsln" + @" """ + _slnPath + @""" """ + _projPath + @""" """ + "command" + @""""; using (System.Diagnostics.Process process = new System.Diagnostics.Process()) { process.StartInfo = new System.Diagnostics.ProcessStartInfo() { WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal, FileName = _pluginInstallerPath, Arguments = _arguments, UseShellExecute = false }; process.Start(); built = process.WaitForExit(timeout) && process.ExitCode == 0; _exitCode = process.ExitCode; } if (built) { Log(ELogVerbosity.Log, "Solution Was Compiled Successfully."); } else if (_exitCode == 1) { Log(ELogVerbosity.Error, "There was an error building the Solution, Please Try Compiling Manually At " + _slnPath); } else if (_exitCode == 2) { Log(ELogVerbosity.Error, "Couldn't Build Custom Solution Because Files Provided were Invalid. Arguments: " + _arguments); } else if (_exitCode == 3) { Log(ELogVerbosity.Error, "Didn't provide the correct number of arguments for buildcustomsln command. Arguments: " + _arguments); } else { Log(ELogVerbosity.Error, "Couldn't Compile Solution, Please Try Compiling Manually At " + _slnPath); } }
private static void CompileGeneratedCode() { CodeGeneratorSettings settings = new CodeGeneratorSettings(); string slnPath = Path.GetFullPath(Path.Combine(settings.GetManagedModulesDir(), "UnrealEngine.sln")); string projPath = Path.GetFullPath(Path.Combine(settings.GetManagedModulesDir(), "UnrealEngine.csproj")); string pluginInstallerPath = Path.GetFullPath(Path.Combine(settings.GetManagedBinDir(), "PluginInstaller", "PluginInstaller.exe")); if (!File.Exists(slnPath)) { CommandLog(ELogVerbosity.Error, "The solution '" + slnPath + "' doesn't exist"); return; } if (!File.Exists(projPath)) { CommandLog(ELogVerbosity.Error, "The project '" + projPath + "' doesn't exist"); return; } if (!File.Exists(pluginInstallerPath)) { CommandLog(ELogVerbosity.Error, "Plugin installer not found at '" + pluginInstallerPath + "'"); return; } const string typeName = "PluginInstaller.Program"; const string methodName = "BuildCustomSolution"; if (pluginInstallerBuildSlnMethod == null) { if (!pluginInstallerLoaded) { pluginInstallerLoaded = true; Assembly assembly = CurrentAssemblyContext.LoadFrom(pluginInstallerPath); if (assembly == null) { CommandLog(ELogVerbosity.Error, "Failed to load the plugin installer at '" + pluginInstallerPath + "'."); return; } Type type = assembly.GetType(typeName); if (type == null) { CommandLog(ELogVerbosity.Error, "Failed to resolve the plugin installer type '" + typeName + "'."); return; } // Set the AppDirectory path so that it can resolve the local msbuild path (if a local msbuild exists) type.GetField("AppDirectory", BindingFlags.Public | BindingFlags.Static).SetValue( null, Path.GetDirectoryName(pluginInstallerPath)); pluginInstallerBuildSlnMethod = type.GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Static); } if (pluginInstallerBuildSlnMethod == null) { CommandLog(ELogVerbosity.Error, "Failed to resolve the '" + methodName + "' function in plugin installer."); return; } } CommandLog(ELogVerbosity.Log, "Attempting to build generated solution at " + slnPath); using (FScopedSlowTask slowTask = new FScopedSlowTask(100, "Compiling...")) { slowTask.MakeDialog(); try { bool built = (bool)pluginInstallerBuildSlnMethod.Invoke(null, new object[] { slnPath, projPath }); if (built) { CommandLog(ELogVerbosity.Log, "Solution was compiled successfully."); } else { CommandLog(ELogVerbosity.Error, "There was an error building the solution. Try compiling manually at " + slnPath); } } catch (Exception e) { CommandLog(ELogVerbosity.Error, "'" + methodName + "' throw an exception whilst compiling: " + e); } // This will give us one frame of 100% rather than always showing 0% (is there an alternative dialog for unknown task lengths?) slowTask.EnterProgressFrame(99.9f); slowTask.EnterProgressFrame(0.1f); } }