private static bool Build(BuildTarget buildTarget, string targetDir, string fileName, string[] scenes, string branch, string version, int buildNumber) { CheckScenes(scenes); CleanTargetDir(targetDir); Debug.LogFormat("Starting build pipeline: target dir {0}, filename {1}", targetDir, fileName); bool isProduction = IsProductionBranch(branch); SetProductionBuildDefine(isProduction, BuildPipeline.GetBuildTargetGroup(buildTarget)); Version versionInfo = UpdateVersionAsset(buildNumber, version, branch); SetVersionInPlayerSettings(versionInfo); // makes the internal name of the resulting executable reflect the product name specified string currentPlayerName = PlayerSettings.productName; PlayerSettings.productName = ProductNameWithBranch(isProduction ? "" : branch); BuildReport result = BuildPipeline.BuildPlayer(scenes, Path.GetFullPath(Path.Combine(targetDir, fileName)), buildTarget, BuildOptions.None); Debug.LogFormat("Build pipeline finished"); // reset player settings PlayerSettings.productName = currentPlayerName; if (result.summary.result != BuildResult.Succeeded) { Debug.LogErrorFormat("ERROR: Build Failed: {0}", result); return(false); } return(true); }
private static void SetVersionInPlayerSettings(Version versionInfo) { PlayerSettings.bundleVersion = versionInfo.versionString; PlayerSettings.Android.bundleVersionCode = versionInfo.buildNumber; }