private static void GenerateTempTarget(FileReference RawProjectPath) { DirectoryReference TempDir = DirectoryReference.Combine(RawProjectPath.Directory, "Intermediate", "Source"); DirectoryReference.CreateDirectory(TempDir); // Get the project name for use in temporary files string ProjectName = RawProjectPath.GetFileNameWithoutExtension(); // Create a target.cs file MemoryStream TargetStream = new MemoryStream(); using (StreamWriter Writer = new StreamWriter(TargetStream)) { Writer.WriteLine("using UnrealBuildTool;"); Writer.WriteLine(); Writer.WriteLine("public class {0}Target : TargetRules", ProjectName); Writer.WriteLine("{"); Writer.WriteLine("\tpublic {0}Target(TargetInfo Target) : base(Target)", ProjectName); Writer.WriteLine("\t{"); Writer.WriteLine("\t\tType = TargetType.Game;"); Writer.WriteLine("\t\tExtraModuleNames.Add(\"{0}\");", ProjectName); Writer.WriteLine("\t}"); Writer.WriteLine("}"); } FileReference TargetLocation = FileReference.Combine(TempDir, ProjectName + ".Target.cs"); FileReference.WriteAllBytesIfDifferent(TargetLocation, TargetStream.ToArray()); // Create a build.cs file MemoryStream ModuleStream = new MemoryStream(); using (StreamWriter Writer = new StreamWriter(ModuleStream)) { Writer.WriteLine("using UnrealBuildTool;"); Writer.WriteLine(); Writer.WriteLine("public class {0} : ModuleRules", ProjectName); Writer.WriteLine("{"); Writer.WriteLine("\tpublic {0}(ReadOnlyTargetRules Target) : base(Target)", ProjectName); Writer.WriteLine("\t{"); Writer.WriteLine("\t\tPCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;"); Writer.WriteLine(); Writer.WriteLine("\t\tPrivateDependencyModuleNames.Add(\"Core\");"); Writer.WriteLine("\t\tPrivateDependencyModuleNames.Add(\"Core\");"); Writer.WriteLine("\t}"); Writer.WriteLine("}"); } FileReference ModuleLocation = FileReference.Combine(TempDir, ProjectName + ".Build.cs"); FileReference.WriteAllBytesIfDifferent(ModuleLocation, ModuleStream.ToArray()); // Create a main module cpp file MemoryStream SourceFileStream = new MemoryStream(); using (StreamWriter Writer = new StreamWriter(SourceFileStream)) { Writer.WriteLine("#include \"CoreTypes.h\""); Writer.WriteLine("#include \"Modules/ModuleManager.h\""); Writer.WriteLine(); Writer.WriteLine("IMPLEMENT_PRIMARY_GAME_MODULE(FDefaultModuleImpl, {0}, \"{0}\");", ProjectName); } FileReference SourceFileLocation = FileReference.Combine(TempDir, ProjectName + ".cpp"); FileReference.WriteAllBytesIfDifferent(SourceFileLocation, SourceFileStream.ToArray()); }