From 1f5e83eaf1c3985ef41b5bf756814672f04e9678 Mon Sep 17 00:00:00 2001 From: Andrew Kahr <22359829+AndrewKahr@users.noreply.github.com> Date: Sun, 15 Oct 2023 17:23:29 -0700 Subject: [PATCH] Fix pathing issues for android keystore --- dist/platforms/windows/build.ps1 | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/dist/platforms/windows/build.ps1 b/dist/platforms/windows/build.ps1 index 50ae2795..bcf270a0 100644 --- a/dist/platforms/windows/build.ps1 +++ b/dist/platforms/windows/build.ps1 @@ -66,6 +66,26 @@ else Get-ChildItem -Path $Env:UNITY_PROJECT_PATH\Assets\Editor -Recurse } +if ( "$Env:BUILD_TARGET" -eq "Android" -and -not ([string]::IsNullOrEmpty("$Env:ANDROID_KEYSTORE_BASE64")) ) +{ + Write-Output "Creating Android keystore." + + # Write to consistent location as Windows Unity seems to have issues with pwd and can't find the keystore + $keystorePath = "C:/android.keystore" + [System.IO.File]::WriteAllBytes($keystorePath, [System.Convert]::FromBase64String($Env:ANDROID_KEYSTORE_BASE64)) + + # Ensure the project settings are pointed at the correct path + $unitySettingsPath = "$Env:GITHUB_WORKSPACE\ProjectSettings\ProjectSettings.asset" + $fileContent = Get-Content -Path "$unitySettingsPath" + $fileContent = $fileContent -replace "AndroidKeystoreName:\s+.*", "AndroidKeystoreName: $keystorePath" + $fileContent | Set-Content -Path "$unitySettingsPath" + + Write-Output "Created Android keystore." +} +else { + Write-Output "Not creating Android keystore." +} + # # Pre-build debug information # @@ -121,7 +141,6 @@ $_, $customParametersArray = Invoke-Expression('Write-Output -- "" ' + $Env:CUST -customBuildPath $Env:CUSTOM_BUILD_PATH ` -buildVersion $Env:VERSION ` -androidVersionCode $Env:ANDROID_VERSION_CODE ` - -androidKeystoreName $Env:ANDROID_KEYSTORE_NAME ` -androidKeystorePass $Env:ANDROID_KEYSTORE_PASS ` -androidKeyaliasName $Env:ANDROID_KEYALIAS_NAME ` -androidKeyaliasPass $Env:ANDROID_KEYALIAS_PASS `