private void RunReflection(StartupArgumentInfo info) { int maxI = info.GetCommandEntries(CommandKeys[0]); for (int i = 0; i < maxI; i++) { ReflectData(info.GetValues(CommandKeys[0], i).ToArray()); } }
private static void CreateEnginePackage(StartupArgumentInfo info, string[] args) { //1 Directory of unpacked game build //2 The Project Name(Must have the same name as the dll that is used to start) //3 The OutputFile //4 True/False flag that enables copying asset files from the project dir if no filelist has been given. //5 Optional File List try { Console.WriteLine(Path.GetFullPath(args[0])); Console.WriteLine(Path.GetFullPath(args[1])); string fileList; if (args.Length > 2) { fileList = Path.GetFullPath(args[2]); Console.WriteLine(Path.GetFullPath(args[2])); } else { fileList = ""; } string csF = Path.GetFullPath(args[0]); string folder = Path.GetDirectoryName(csF) + "/bin/Release/netcoreapp2.1/publish"; if (Directory.Exists(folder + "/bin")) { Console.WriteLine("Deleting publish folder to prevent copying the wrong assemblies."); Directory.Delete(folder + "/bin", true); } if (Directory.Exists(folder + "/obj")) { Console.WriteLine("Deleting publish folder to prevent copying the wrong assemblies."); Directory.Delete(folder + "/obj", true); } string packagerVersion = Creator.DefaultVersion; if (info.GetCommandEntries("--packager-version") != 0) { packagerVersion = info.GetValues("--packager-version")[0]; } Builder.BuildProject(csF); string[] files = Builder.ParseEngineFileList(fileList, folder); Creator.CreateEnginePackage(Path.GetFullPath(args[1]), folder, files, packagerVersion); } catch (Exception e) { throw new BuilderInputException("Input Error", e); } }
private static void CreateGamePackage(StartupArgumentInfo info, string[] args) { //1 Directory of unpacked game build //2 The Project Name(Must have the same name as the dll that is used to start) //3 The OutputFile //4 True/False flag that enables copying asset files from the project dir if no filelist has been given. //5 Optional File List try { Console.WriteLine(Path.GetFullPath(args[0])); Console.WriteLine(Path.GetFullPath(args[2])); string version = ""; if (info.GetCommandEntries("--packer-override-engine-version") == 0) { FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(Path.GetFullPath(args[0]) + "/Engine.dll"); version = fvi.FileVersion; } else { version = info.GetValues("--packer-override-engine-version")[0]; } string fileList; if (args.Length > 5) { fileList = Path.GetFullPath(args[5]); Console.WriteLine(Path.GetFullPath(args[5])); } else { fileList = ""; } bool standalone = version == "standalone"; string packagerVersion = Creator.DefaultVersion; string startArg = args[1] + ".dll"; if (info.GetCommandEntries("--packager-version") != 0) { packagerVersion = info.GetValues("--packager-version")[0]; if (packagerVersion == "v2") { if (info.GetCommandEntries("--set-start-args") == 0) { Console.WriteLine("Warning. no startup arguments specifed!"); startArg = "dotnet " + args[1] + ".dll"; } else { string[] a = info.GetValues("--set-start-args").ToArray(); startArg = a[0]; StringBuilder sb = new StringBuilder(a[0]); for (int i = 1; i < a.Length; i++) { sb.Append(" " + a[i]); } startArg = sb.ToString(); } } } string[] files = Builder.ParseFileList(fileList, Path.GetFullPath(args[0]), args[1], bool.Parse(args[3]), bool.Parse(args[4]), standalone); Creator.CreateGamePackage(args[1], startArg, Path.GetFullPath(args[2]), Path.GetFullPath(args[0]), files, version, packagerVersion); } catch (Exception e) { throw new BuilderInputException("Input Error", e); } }
private static void BuildXML(StartupArgumentInfo info, string[] args) { if (args.Length != 0) { string file = args[0]; if (File.Exists(file)) { BuildSettings bs = Builder.LoadSettings(file); Directory.SetCurrentDirectory(Path.GetDirectoryName(Path.GetFullPath(file))); string outFolder = Path.GetFullPath(bs.OutputFolder); if (!Directory.Exists(outFolder)) { Directory.CreateDirectory(outFolder); } string buildOutput = bs.CreateGamePackage ? outFolder + "/build" : outFolder; string outputFolder = Path.GetFullPath(bs.OutputFolder); string projectFile = Path.GetFullPath(bs.Project); string projectFolder = Path.GetDirectoryName(projectFile); projectFolder = Path.GetFullPath(projectFolder); string assetFolder = Path.GetFullPath(bs.AssetFolder); string projectName = Path.GetFileNameWithoutExtension(projectFile); string publishFolder = projectFolder + "/bin/Release/netcoreapp2.1/publish"; if (Directory.Exists(projectFolder + "/bin")) { Console.WriteLine("Deleting publish folder to prevent copying the wrong assemblies."); Directory.Delete(projectFolder + "/bin", true); } if (Directory.Exists(projectFolder + "/obj")) { Console.WriteLine("Deleting publish folder to prevent copying the wrong assemblies."); Directory.Delete(projectFolder + "/obj", true); } string filePatterns = bs.UnpackFiles + "+" + bs.MemoryFiles; string outputPackFolder = bs.BuildFlags == BuildType.PackOnly ? "/packs" : "/" + projectName; string packSubFolder = bs.BuildFlags == BuildType.PackOnly ? "" : "/" + projectName; string packFolder = projectFolder + packSubFolder; bool packsCreated = false; if ((bs.BuildFlags == BuildType.PackEmbed || bs.BuildFlags == BuildType.PackOnly) && Directory.Exists(assetFolder)) { Builder.PackAssets(packFolder, bs.PackSize, bs.MemoryFiles, bs.UnpackFiles, assetFolder, false); packsCreated = true; } if (bs.BuildFlags == BuildType.PackEmbed || bs.BuildFlags == BuildType.Embed) { string[] files; if (packsCreated) { Console.WriteLine("Embedding Packs."); files = Directory.GetFiles(projectFolder + "/" + projectName, "*", SearchOption.AllDirectories); } else { Console.WriteLine("Embedding Files."); files = CreateFileList(assetFolder, filePatterns); } AssemblyEmbedder.EmbedFilesIntoProject(projectFile, files); } Builder.BuildProject(projectFolder); if (Directory.Exists(buildOutput)) { Directory.Delete(buildOutput, true); } Thread.Sleep(500); Directory.Move(publishFolder, buildOutput); string[] debugFiles = Directory.GetFiles(buildOutput, "*.pdb", SearchOption.AllDirectories); for (int i = 0; i < debugFiles.Length; i++) { File.Delete(debugFiles[i]); } if (bs.BuildFlags == BuildType.PackEmbed || bs.BuildFlags == BuildType.Embed) { Console.WriteLine("Unembedding items."); AssemblyEmbedder.UnEmbedFilesFromProject(projectFile); } if (packsCreated && bs.BuildFlags == BuildType.PackOnly) { Console.WriteLine("Copying Packs to Output."); Directory.Move(projectFolder + outputPackFolder, buildOutput + outputPackFolder); } else if (packsCreated && bs.BuildFlags == BuildType.PackEmbed) { Console.WriteLine("Deleting Generated Pack Folder."); Directory.Delete(projectFolder + outputPackFolder, true); } if (bs.BuildFlags == BuildType.Copy) { Console.WriteLine("Copying Assets to output"); string buildAssetDir = assetFolder.Replace(projectFolder, buildOutput); Directory.CreateDirectory(buildAssetDir); foreach (string dirPath in Directory.GetDirectories(assetFolder, "*", SearchOption.AllDirectories)) { Directory.CreateDirectory(dirPath.Replace(projectFolder, buildOutput)); } //Copy all the files & Replaces any files with the same name foreach (string newPath in Directory.GetFiles(assetFolder, "*.*", SearchOption.AllDirectories)) { File.Copy(newPath, newPath.Replace(projectFolder, buildOutput), true); } } if (bs.CreateGamePackage) { string packagerVersion = string.IsNullOrEmpty(bs.PackagerVersion) ? Creator.DefaultVersion : bs.PackagerVersion; if (info.GetCommandEntries("--packager-version") != 0) { packagerVersion = info.GetValues("--packager-version")[0]; } string startArg = projectName + ".dll"; if (packagerVersion == "v2") { if (info.GetCommandEntries("--set-start-args") == 0) { Console.WriteLine("Warning. no startup arguments specifed!"); startArg = "dotnet " + projectName + ".dll"; } else { string[] a = info.GetValues("--set-start-args").ToArray(); startArg = a[0]; StringBuilder sb = new StringBuilder(a[0]); for (int i = 1; i < a.Length; i++) { sb.Append(" " + a[i]); } startArg = sb.ToString(); } } FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(buildOutput + "/Engine.dll"); string[] files = Builder.ParseFileList(bs.GamePackageFileList, buildOutput, projectName, bs.BuildFlags == BuildType.Copy, bs.BuildFlags == BuildType.PackOnly, false); Creator.CreateGamePackage(projectName, startArg, outputFolder + "/" + projectName + ".game", buildOutput, files, fvi.FileVersion, packagerVersion); } } } }