Skip to content

Commit 068273a

Browse files
authored
fix: throw errors from the Unity CLI in the Windows build command (#38)
1 parent a9489e1 commit 068273a

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/scripts/windows/build.sh

+23-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/false
22
# shellcheck shell=bash
3-
# shellcheck disable=SC2154
3+
# shellcheck disable=SC2016,SC2154
44

55
trap_exit() {
66
local exit_status="$?"
@@ -25,13 +25,34 @@ docker exec "$CONTAINER_NAME" powershell "[System.Environment]::SetEnvironmentVa
2525
docker exec "$CONTAINER_NAME" powershell "[System.Environment]::SetEnvironmentVariable('BUILD_METHOD','$build_method', [System.EnvironmentVariableTarget]::Machine)"
2626
docker exec "$CONTAINER_NAME" powershell "[System.Environment]::SetEnvironmentVariable('CUSTOM_PARAMS','$custom_parameters', [System.EnvironmentVariableTarget]::Machine)"
2727

28+
build_args=(
29+
'-batchmode'
30+
'-quit'
31+
'-nographics'
32+
'-projectPath $Env:PROJECT_PATH'
33+
'-buildTarget $Env:BUILD_TARGET'
34+
'-customBuildTarget $Env:BUILD_TARGET'
35+
'-customBuildName $Env:BUILD_NAME'
36+
'-customBuildPath "C:/build/"'
37+
'-executeMethod $Env:BUILD_METHOD'
38+
)
39+
40+
[ -n "$custom_parameters" ] && build_args+=( '$Env:CUSTOM_PARAMS.split()' )
41+
2842
# Build the project
2943
# Versioning of the project needs work. This is how it's done in the GHA:
3044
# https://github.com/game-ci/unity-builder/blob/main/src/model/versioning.ts
3145
set -x
32-
docker exec "$CONTAINER_NAME" powershell '& "C:\Program Files\Unity\Hub\Editor\*\Editor\Unity.exe" -batchmode -quit -nographics -projectPath $Env:PROJECT_PATH -buildTarget $Env:BUILD_TARGET -customBuildTarget $Env:BUILD_TARGET -customBuildName $Env:BUILD_NAME -customBuildPath "C:/build/" -executeMethod $Env:BUILD_METHOD $Env:CUSTOM_PARAMS.split() -logfile | Out-Host'
46+
docker exec "$CONTAINER_NAME" powershell "& 'C:\Program Files\Unity\Hub\Editor\*\Editor\Unity.exe' ${build_args[*]} -logfile | Out-Host"
47+
exit_code="$?"
3348
set +x
3449

50+
if [ "$exit_code" -ne 0 ]; then
51+
printf '%s\n' "Failed to build the project."
52+
printf '%s\n' "Please try again, open an issue or reach out to us on Discord."
53+
exit "$exit_code"
54+
fi
55+
3556
# Compress the build folder.
3657
docker exec "$CONTAINER_NAME" powershell 'tar -czf "C:/$Env:BUILD_NAME-$Env:BUILD_TARGET.tar.gz" -C "C:/build" .'
3758

0 commit comments

Comments
 (0)