From a509068b8a9040ead2061125b500c64e9ba260f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Thu, 5 Dec 2024 10:49:21 +0100 Subject: [PATCH] v1.0.12 --- CHANGELOG.md | 6 ++++++ Editor/AzurePipelinesBuildTemplate.cs | 8 ++++++-- Editor/Utilities.cs | 17 ++++++++++++++++- package.json | 2 +- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25644cc..3ccdb7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.0.12] + +### Added + +- Added handling CLI argument `-buildAppBundle` to produce an .abb file instead of .apk when building for Android + ## [1.0.11] ### Added diff --git a/Editor/AzurePipelinesBuildTemplate.cs b/Editor/AzurePipelinesBuildTemplate.cs index 496c38f..376a4cd 100644 --- a/Editor/AzurePipelinesBuildTemplate.cs +++ b/Editor/AzurePipelinesBuildTemplate.cs @@ -16,6 +16,7 @@ public static class AzurePipelinesBuild private const string AndroidKeystorePassArgument = "-keystorePass"; private const string AndroidKeystoreAliasNameArgument = "-keystoreAliasName"; private const string AndroidKeystoreAliasPassArgument = "-keystoreAliasPass"; + private const string AndroidBuildAppBundleArgument = "-buildAppBundle"; public static void PerformBuild() { @@ -27,9 +28,9 @@ public static void PerformBuild() return; } - // When building for Android, check for custom keystore signing credentials and apply them prior to building the project. if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android) { + // When building for Android, check for custom keystore signing credentials and apply them prior to building the project. if (Dinomite.AzurePipelines.Utilities.TryGetCommandLineArgumentValue(AndroidKeystoreNameArgument, out var androidKeystoreName) && Dinomite.AzurePipelines.Utilities.TryGetCommandLineArgumentValue(AndroidKeystorePassArgument, out var androidKeystorePass) && Dinomite.AzurePipelines.Utilities.TryGetCommandLineArgumentValue(AndroidKeystoreAliasNameArgument, out var androidKeystoreAliasName)) @@ -49,6 +50,9 @@ public static void PerformBuild() // would cause the build to fail. PlayerSettings.Android.useCustomKeystore = false; } + + // When building for Android, we might want to build an .aab for the Play Store instead of an .apk file. + EditorUserBuildSettings.buildAppBundle = Dinomite.AzurePipelines.Utilities.CommandLineArgumentExists(AndroidBuildAppBundleArgument); } try @@ -118,7 +122,7 @@ private static string GetBuildTargetOutputFileNameAndExtension(string outputFile switch (EditorUserBuildSettings.activeBuildTarget) { case BuildTarget.Android: - return string.Format("{0}.apk", outputFileName); + return string.Format("{0}.{1}", outputFileName, EditorUserBuildSettings.buildAppBundle ? "aab" : "apk"); case BuildTarget.StandaloneWindows64: case BuildTarget.StandaloneWindows: return string.Format("{0}.exe", outputFileName); diff --git a/Editor/Utilities.cs b/Editor/Utilities.cs index c13c881..7f9dfed 100644 --- a/Editor/Utilities.cs +++ b/Editor/Utilities.cs @@ -2,13 +2,28 @@ namespace Dinomite.AzurePipelines { public static class Utilities { + public static bool CommandLineArgumentExists(string argumentName) + { + var commandLineArguments = System.Environment.GetCommandLineArgs(); + + for (var i = 0; i < commandLineArguments.Length; i++) + { + if (string.Equals(commandLineArguments[i], argumentName)) + { + return true; + } + } + + return false; + } + public static bool TryGetCommandLineArgumentValue(string argumentName, out string value) { var commandLineArguments = System.Environment.GetCommandLineArgs(); for (var i = 0; i < commandLineArguments.Length; i++) { - if (commandLineArguments[i] == argumentName && i + 1 < commandLineArguments.Length) + if (string.Equals(commandLineArguments[i], argumentName) && i + 1 < commandLineArguments.Length) { value = commandLineArguments[i + 1]; return true; diff --git a/package.json b/package.json index c630b4f..add51f6 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "games.dinomite.azurepipelines", "displayName": "Dinomite.AzurePipelines", "description": "A Unity package containing build scripts for use with the Unity Tools for Azure DevOps extension.", - "version": "1.0.11", + "version": "1.0.12", "unity": "2018.1", "author": "Dinomite", "keywords": [