Fix powershell quotation issue, when CUSTOM_PARAMETERS contains spaces (#470)

This commit is contained in:
Eric Roy 2022-10-31 03:12:56 -07:00 committed by GitHub
parent 4cb3e593f5
commit 96555a0945
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -109,6 +109,10 @@ Write-Output "# Building project #"
Write-Output "###########################" Write-Output "###########################"
Write-Output "" Write-Output ""
# If $Env:CUSTOM_PARAMETERS contains spaces and is passed directly on the command line to Unity, powershell will wrap it
# in double quotes. To avoid this, parse $Env:CUSTOM_PARAMETERS into an array, while respecting any quotations within the string.
$_, $customParametersArray = Invoke-Expression('Write-Output -- "" ' + $Env:CUSTOM_PARAMETERS)
& "C:\Program Files\Unity\Hub\Editor\$Env:UNITY_VERSION\Editor\Unity.exe" -quit -batchmode -nographics ` & "C:\Program Files\Unity\Hub\Editor\$Env:UNITY_VERSION\Editor\Unity.exe" -quit -batchmode -nographics `
-projectPath $Env:UNITY_PROJECT_PATH ` -projectPath $Env:UNITY_PROJECT_PATH `
-executeMethod $Env:BUILD_METHOD ` -executeMethod $Env:BUILD_METHOD `
@ -122,7 +126,7 @@ Write-Output ""
-androidKeyaliasName $Env:ANDROID_KEYALIAS_NAME ` -androidKeyaliasName $Env:ANDROID_KEYALIAS_NAME `
-androidKeyaliasPass $Env:ANDROID_KEYALIAS_PASS ` -androidKeyaliasPass $Env:ANDROID_KEYALIAS_PASS `
-androidTargetSdkVersion $Env:ANDROID_TARGET_SDK_VERSION ` -androidTargetSdkVersion $Env:ANDROID_TARGET_SDK_VERSION `
$Env:CUSTOM_PARAMETERS ` $customParametersArray `
-logfile | Out-Host -logfile | Out-Host
# Catch exit code # Catch exit code