示例#1
0
        public static BuildAppResult BuildApk(
            string unityExePath,
            string nssUnityProj,
            BuildMode buildMode,
            bool prepareProject,
            string sdkRoot,
            string ndkRoot,
            string jdkRoot,
            string versionJsonPath  = null,
            VerLine verLine         = VerLine.DB,
            PackageType packageType = PackageType.Normal,
            BuildOption buildOption = BuildOption.None,
            string toolsDir         = "../Tools",
            string outputDir        = "Output",
            int svnRev = -1)
        {
            ModifyMacro(nssUnityProj, buildMode, packageType, buildOption);

            var result = new BuildAppResult();

            result.defaultTDir = ModifyDefaultLaunch(nssUnityProj, verLine, buildMode);

            var unityExe       = new Executable(unityExePath);
            var unityArguments = $"-batchmode -quit -logFile \"{SpaceUtil.GetPathInTemp("log.log", true)}\" -projectPath \"{nssUnityProj}\" -executeMethod \"NssIntegration.BuildProcedure.Entry\" -l \"{SpaceUtil.GetPathInTemp("log2.log", true)}\"";

            if (prepareProject)
            {
                unityArguments += $" PrepareProject {buildMode} {BuildTarget.Android} \"{versionJsonPath}\" {packageType} {buildOption} \"{toolsDir}\"";
            }
            unityArguments += $" BuildApk {buildMode} \"{sdkRoot}\" \"{ndkRoot}\" \"{jdkRoot}\" {verLine} {packageType} {buildOption} \"{toolsDir}\" \"{outputDir}\" {svnRev}";
            unityExe.Execute(unityArguments);

            var apks = Directory.GetFiles(outputDir, "*.apk");

            if (apks.Length != 1)
            {
                throw new NssIntegrationException($"'{outputDir}'中有{apks.Length}个apk文件,不合理!");
            }
            result.appPath    = apks[0];
            result.appVersion = ClientVersion.New(versionJsonPath).ToString();

            return(result);
        }
示例#2
0
        static void Main(string[] args)
        {
            SpaceUtil.SetTempSpace("temp");

            var logFile = SpaceUtil.GetPathInTemp($"NssIntegrationStart_{DateTime.Now.ToString("yyyyMMddhhmmss")}.log");

            Logger.SetLogFile("NssIntegrationStart", new LogFile(logFile));
            Logger.BeginMuteConsoleOutput();

            CLApp.Init("NssIntegration");

            var envConfigPath = SpaceUtil.GetPathInBase($"Config{Path.DirectorySeparatorChar}EnvConfig.json");
            Dictionary <string, string> dicEnvConfig = null;

            if (File.Exists(envConfigPath))
            {
                JsonSerializer jsonSerializer = new JsonSerializer();
                dicEnvConfig = (Dictionary <string, string>)jsonSerializer.Deserialize(new StreamReader(envConfigPath), typeof(Dictionary <string, string>));
            }

            // 初始化各种工具类
            SvnUtil.Init(() => GetEnv(envConfigPath, dicEnvConfig, "SvnBin"));
            ApkTool.Init(() => GetEnv(envConfigPath, dicEnvConfig, "ApkTool"));
            IntegrationServer.Init(() => GetEnv(envConfigPath, dicEnvConfig, "IntegrationServerAddress"));
            IFSUtil.Init(() => GetEnv(envConfigPath, dicEnvConfig, "IIPS"));

            CLApp.AddCommand(NewMethodCommand(typeof(BuildProcedure), "AssemblyApk"));
            CLApp.AddCommand(NewMethodCommand(typeof(BuildProcedure), "PrepareUniqueVersionJson"));
            CLApp.AddCommand(NewMethodCommand(typeof(BuildProcedure), "ModifyMacro"));
            CLApp.AddCommand(NewMethodCommand(typeof(BuildProcedure), "BuildApk"));
            CLApp.AddCommand(NewMethodCommand(typeof(BuildEntry), "UnpackIFS"));
            CLApp.AddCommand(NewMethodCommand(typeof(BuildEntry), "Build"));

            Logger.SetLogFile("NssIntegrationStart", null);
            Logger.EndMuteConsoleOutput();

            CLApp.Launch(args);
        }