Ejemplo n.º 1
0
        private static void PerformBuild(string[] buildConfigs, BuildOptions options = BuildOptions.None)
        {
            int successCount = 0;
            int failCount    = 0;

            // Save current script defines, build constants, etc. so we can restore them after build.
            string buildConstantsPath        = BuildConstantsGenerator.FindFile();
            string currentBuildConstantsFile = null;

            if (!string.IsNullOrEmpty(buildConstantsPath))
            {
                currentBuildConstantsFile = FileUtil.GetUniqueTempPathInProject();
                File.Copy(buildConstantsPath, currentBuildConstantsFile);
            }

            DateTime buildTime;

            PerformPreBuild(out buildTime);

            for (int i = 0; i < buildConfigs.Length; i++)
            {
                BuildReleaseType  releaseType;
                BuildPlatform     platform;
                BuildArchitecture arch;
                BuildDistribution dist;
                string            configKey = buildConfigs[i];

                // Parse build config and perform build.
                string notification = string.Format("Building ({0}/{1}): ", i + 1, buildConfigs.Length);
                BuildSettings.projectConfigurations.ParseKeychain(configKey, out releaseType, out platform, out arch, out dist);
                bool success = BuildPlayer(notification, releaseType, platform, arch, dist, buildTime, options, configKey);

                if (success)
                {
                    ++successCount;
                }
                else
                {
                    ++failCount;
                }
            }

            PerformPostBuild();

            // Restore editor status.
            if (!string.IsNullOrEmpty(buildConstantsPath))
            {
                File.Copy(currentBuildConstantsFile, buildConstantsPath, true);
                File.Delete(currentBuildConstantsFile);
            }

            // Report success/failure.
            StringBuilder sb = new StringBuilder();

            if (failCount == 0)
            {
                sb.AppendFormat("{0} successful build{1}. No failures. ✔️",
                                successCount, successCount > 1 ? "s" : "");
            }
            else if (successCount == 0)
            {
                sb.AppendFormat("No successful builds. {0} failure{1}. ✖️",
                                failCount, failCount > 1 ? "s" : "");
            }
            else
            {
                sb.AppendFormat("{0} successful build{1}. {2} failure{3}.",
                                successCount, successCount > 1 ? "s" : "",
                                failCount, failCount > 1 ? "s" : "");
            }
            BuildNotificationList.instance.AddNotification(new BuildNotification(
                                                               BuildNotification.Category.Notification,
                                                               "Build Complete.", sb.ToString(),
                                                               true, null));

            // Open output folder if option is enabled.
            if (BuildSettings.basicSettings.openFolderPostBuild)
            {
                System.Diagnostics.Process.Start(BuildSettings.basicSettings.baseBuildFolder);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 执行生成
        /// </summary>
        /// <param 生成配置="buildConfigs"></param>
        /// <param 生成选项="options"></param>
        private static void PerformBuild(string[] buildConfigs, BuildOptions options = BuildOptions.None)
        {
            int successCount = 0;
            int failCount    = 0;

            // Save current script defines, build constants, etc. so we can restore them after build.保存当前脚本定义、生成常量等,以便我们可以在生成后还原它们。
            string buildConstantsPath        = BuildConstantsGenerator.FindFile(); //生成常量路径
            string currentBuildConstantsFile = null;                               //当前生成常量文件

            if (!string.IsNullOrEmpty(buildConstantsPath))
            {
                currentBuildConstantsFile = FileUtil.GetUniqueTempPathInProject();
                File.Copy(buildConstantsPath, currentBuildConstantsFile);
            }

            DateTime buildTime;//时间

            PerformPreBuild(out buildTime);
            Debug.Log("+++++++" + buildTime);
            for (int i = 0; i < buildConfigs.Length; i++)      //生成配置
            {
                BuildReleaseType releaseType;                  //生成发布类型
                //  BuildReleaseType releaseType = BuildReleaseType.ReferenceEquals.;//生成发布类型
                BuildPlatform     platform;                    //平台
                BuildArchitecture arch;                        //体系结构
                BuildDistribution dist;                        //分发
                string            configKey = buildConfigs[i]; //配置键

                // Parse build config and perform build.//分析生成配置并执行生成。
                string notification = string.Format("Building ({0}/{1}): ", i + 1, buildConfigs.Length);//通知
                BuildSettings.projectConfigurations.ParseKeychain(configKey, out releaseType, out platform, out arch, out dist);
                Debug.Log("scccc");
                // BuildPlayer(notification, releaseType, platform, arch, dist, buildTime, options, configKey);
                bool success = BuildPlayer(notification, releaseType, platform, arch, dist, buildTime, options, configKey);

                if (success)
                {
                    ++successCount;
                }
                else
                {
                    ++failCount;
                }
            }

            PerformPostBuild();

            // Restore editor status.还原编辑器状态。
            if (!string.IsNullOrEmpty(buildConstantsPath))
            {
                File.Copy(currentBuildConstantsFile, buildConstantsPath, true);
                File.Delete(currentBuildConstantsFile);
            }

            // 报告成功/失败。
            StringBuilder sb = new StringBuilder();

            if (failCount == 0)
            {
                sb.AppendFormat("{0} successful build{1}. No failures. ✔️",
                                successCount, successCount > 1 ? "s" : "");
            }
            else if (successCount == 0)
            {
                sb.AppendFormat("No successful builds. {0} failure{1}. ✖️",
                                failCount, failCount > 1 ? "s" : "");
            }
            else
            {
                sb.AppendFormat("{0} successful build{1}. {2} failure{3}.",
                                successCount, successCount > 1 ? "s" : "",
                                failCount, failCount > 1 ? "s" : "");
            }
            BuildNotificationList.instance.AddNotification(new BuildNotification(
                                                               BuildNotification.Category.Notification,
                                                               "Build Complete.", sb.ToString(),
                                                               true, null));

            // Open output folder if option is enabled.如果选项已启用,请打开输出文件夹。
            if (BuildSettings.basicSettings.openFolderPostBuild)
            {
                ///开路径的方法先不要了
                // System.Diagnostics.Process.Start(BuildSettings.basicSettings.baseBuildFolder);
            }
        }