コード例 #1
0
        private void SetBuildConfig(StartupArgumentInfo argumentInfo, string[] args)
        {
            if (!Program.HasTarget)
            {
                Logger.Log(LogType.Error, "You need to specify a target config");
                return;
            }

            if (args.Length != 1)
            {
                Logger.Log(LogType.Error, "Only 1 argument allowed.");
                return;
            }

            AssemblyDefinition definition = AssemblyDefinition.Load(Program.Target);

            definition.BuildConfiguration = args[0];
            AssemblyDefinition.Save(Program.Target, definition);
        }
コード例 #2
0
 private static void KillInstances(StartupArgumentInfo info, string[] args)
 {
     int[] ports = new int[args.Length];
     if (args.Length != 0)
     {
         for (int i = 0; i < args.Length; i++)
         {
             ports[i] = int.Parse(args[i]);
         }
     }
     else
     {
         GameInstanceInfo[] sis = Program.MatchMaker.GetInstanceInfos();
         ports = new int[sis.Length];
         for (int i = 0; i < sis.Length; i++)
         {
             ports[i] = sis[i].Port;
         }
     }
     Program.MatchMaker.StopGameInstances(ports);
 }
コード例 #3
0
        private void SetTargetRuntime(StartupArgumentInfo argumentInfo, string[] args)
        {
            if (!Program.HasTarget)
            {
                Logger.Log(LogType.Error, "You need to specify a target config");
                return;
            }

            if (args.Length != 1)
            {
                Logger.Log(LogType.Error, "Only 1 argument allowed.");
                return;
            }

            AssemblyDefinition definition = AssemblyDefinition.Load(Program.Target);

            Logger.Log(LogType.Log, "Setting Target Runtime: " + args[0]);
            definition.NoTargetRuntime    = args[0].ToLower() == "none";
            definition.BuildTargetRuntime = args[0];

            AssemblyDefinition.Save(Program.Target, definition);
        }
コード例 #4
0
ファイル: BuildCommand.cs プロジェクト: codacy-badger/Byt3
        private void Build(StartupArgumentInfo argumentInfo, string[] args)
        {
            if (!Program.HasTarget)
            {
                Logger.Log(LogType.Log, "You need to specify a target config");
                return;
            }

            AssemblyDefinition def = AssemblyDefinition.Load(Program.Target);

            AssemblyGeneratorBuildType buildType = AssemblyGeneratorBuildType.Publish;

            if (args.Length == 1 && !Enum.TryParse(args[0], out buildType))
            {
                Logger.Log(LogType.Log, "Can not parse the BuildType. Using Default:" + buildType);
            }

            string path = Path.Combine(Path.GetDirectoryName(Program.Target), $"{def.AssemblyName}_build");

            Logger.Log(LogType.Log, "AAAAAAAAAAAAAA:" + path);
            AssemblyGenerator.GenerateAssembly("dotnet", def, path, buildType, !Program.BuildConsole);
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
ファイル: BuildXMLCommand.cs プロジェクト: ByteChkR/Byt3
        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);
                    }
                }
            }
        }
コード例 #7
0
 private void RunHelpCommand(StartupArgumentInfo info, string[] args)
 {
     DoExecute = false;
     cmd.CommandAction(info, args);
 }
コード例 #8
0
 private static void BuildConsoleFlag(StartupArgumentInfo argumentInfo, string[] args)
 {
     Program.BuildConsole = true;
 }
コード例 #9
0
 private static void Exit(StartupArgumentInfo info, string[] args)
 {
     Program.Exit = true;
 }