mirror of
https://github.com/game-ci/unity-builder.git
synced 2025-07-07 20:35:33 -04:00
Use different method to run unity to ensure it exits without hanging
This commit is contained in:
parent
d74bb9d4ad
commit
32e3b41ff7
7
.vscode/launch.json
vendored
7
.vscode/launch.json
vendored
@ -1,5 +1,12 @@
|
|||||||
{
|
{
|
||||||
"configurations": [
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "PowerShell Launch Current File",
|
||||||
|
"type": "PowerShell",
|
||||||
|
"request": "launch",
|
||||||
|
"script": "${file}",
|
||||||
|
"cwd": "${cwd}"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "node",
|
"type": "node",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
|
53
dist/platforms/windows/build.ps1
vendored
53
dist/platforms/windows/build.ps1
vendored
@ -131,27 +131,44 @@ Write-Output ""
|
|||||||
|
|
||||||
# If $Env:CUSTOM_PARAMETERS contains spaces and is passed directly on the command line to Unity, powershell will wrap it
|
# 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.
|
# 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)
|
$_, $customParametersArray = Invoke-Expression('Write-Output -- "" ' + $Env:CUSTOM_PARAMETERS) | ForEach-Object { $_.ToString() }
|
||||||
|
|
||||||
& "C:\Program Files\Unity\Hub\Editor\$Env:UNITY_VERSION\Editor\Unity.exe" -quit -batchmode -nographics `
|
$process = Start-Process -FilePath "C:\Program Files\Unity\Hub\Editor\$Env:UNITY_VERSION\Editor\Unity.exe" `
|
||||||
-projectPath $Env:UNITY_PROJECT_PATH `
|
-ArgumentList @("-quit",
|
||||||
-executeMethod $Env:BUILD_METHOD `
|
"-batchmode",
|
||||||
-buildTarget $Env:BUILD_TARGET `
|
"-nographics",
|
||||||
-customBuildTarget $Env:BUILD_TARGET `
|
"-projectPath", $Env:UNITY_PROJECT_PATH,
|
||||||
-customBuildPath $Env:CUSTOM_BUILD_PATH `
|
"-executeMethod", $Env:BUILD_METHOD,
|
||||||
-buildVersion $Env:VERSION `
|
"-buildTarget", $Env:BUILD_TARGET,
|
||||||
-androidVersionCode $Env:ANDROID_VERSION_CODE `
|
"-customBuildTarget", $Env:BUILD_TARGET,
|
||||||
-androidKeystorePass $Env:ANDROID_KEYSTORE_PASS `
|
"-customBuildPath", $Env:CUSTOM_BUILD_PATH,
|
||||||
-androidKeyaliasName $Env:ANDROID_KEYALIAS_NAME `
|
"-buildVersion", $Env:VERSION,
|
||||||
-androidKeyaliasPass $Env:ANDROID_KEYALIAS_PASS `
|
"-androidVersionCode", $Env:ANDROID_VERSION_CODE,
|
||||||
-androidTargetSdkVersion $Env:ANDROID_TARGET_SDK_VERSION `
|
"-androidKeystorePass", $Env:ANDROID_KEYSTORE_PASS,
|
||||||
-androidExportType $Env:ANDROID_EXPORT_TYPE `
|
"-androidKeyaliasName", $Env:ANDROID_KEYALIAS_NAME,
|
||||||
-androidSymbolType $Env:ANDROID_SYMBOL_TYPE `
|
"-androidKeyaliasPass", $Env:ANDROID_KEYALIAS_PASS,
|
||||||
$customParametersArray `
|
"-androidTargetSdkVersion", $Env:ANDROID_TARGET_SDK_VERSION,
|
||||||
-logfile | Out-Host
|
"-androidExportType", $Env:ANDROID_EXPORT_TYPE,
|
||||||
|
"-androidSymbolType", $Env:ANDROID_SYMBOL_TYPE,
|
||||||
|
"-logfile", "-", "./build.log",
|
||||||
|
"-silent-crashes"
|
||||||
|
) + $customParametersArray `
|
||||||
|
-NoNewWindow `
|
||||||
|
-PassThru
|
||||||
|
|
||||||
|
# This ensures that the Unity Editor properly exits as it can hang on Windows
|
||||||
|
while (!$process.StandardOutput.EndOfStream) {
|
||||||
|
|
||||||
|
if ($process.HasExited) {
|
||||||
|
Write-Host "`nExecute Method Ended`n"
|
||||||
|
exit 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Start-Sleep -Seconds 1
|
||||||
|
}
|
||||||
|
|
||||||
# Catch exit code
|
# Catch exit code
|
||||||
$Env:BUILD_EXIT_CODE=$LastExitCode
|
$Env:BUILD_EXIT_CODE=$process.ExitCode
|
||||||
|
|
||||||
# Display results
|
# Display results
|
||||||
if ($Env:BUILD_EXIT_CODE -eq 0)
|
if ($Env:BUILD_EXIT_CODE -eq 0)
|
||||||
|
18
dist/platforms/windows/entrypoint.ps1
vendored
18
dist/platforms/windows/entrypoint.ps1
vendored
@ -1,37 +1,21 @@
|
|||||||
Get-Process
|
|
||||||
|
|
||||||
# Import any necessary registry keys, ie: location of windows 10 sdk
|
# Import any necessary registry keys, ie: location of windows 10 sdk
|
||||||
# No guarantee that there will be any necessary registry keys, ie: tvOS
|
# No guarantee that there will be any necessary registry keys, ie: tvOS
|
||||||
Get-ChildItem -Path c:\regkeys -File | Foreach {reg import $_.fullname}
|
Get-ChildItem -Path c:\regkeys -File | ForEach-Object {reg import $_.fullname}
|
||||||
Start-Sleep 3
|
|
||||||
Get-Process
|
|
||||||
|
|
||||||
# Register the Visual Studio installation so Unity can find it
|
# Register the Visual Studio installation so Unity can find it
|
||||||
regsvr32 C:\ProgramData\Microsoft\VisualStudio\Setup\x64\Microsoft.VisualStudio.Setup.Configuration.Native.dll
|
regsvr32 C:\ProgramData\Microsoft\VisualStudio\Setup\x64\Microsoft.VisualStudio.Setup.Configuration.Native.dll
|
||||||
Start-Sleep 3
|
|
||||||
Get-Process
|
|
||||||
|
|
||||||
# Setup Git Credentials
|
# Setup Git Credentials
|
||||||
& "c:\steps\set_gitcredential.ps1"
|
& "c:\steps\set_gitcredential.ps1"
|
||||||
Start-Sleep 3
|
|
||||||
Get-Process
|
|
||||||
|
|
||||||
# Activate Unity
|
# Activate Unity
|
||||||
& "c:\steps\activate.ps1"
|
& "c:\steps\activate.ps1"
|
||||||
Start-Sleep 3
|
|
||||||
Get-Process
|
|
||||||
|
|
||||||
# Build the project
|
# Build the project
|
||||||
& "c:\steps\build.ps1"
|
& "c:\steps\build.ps1"
|
||||||
Start-Sleep 3
|
|
||||||
Get-Process
|
|
||||||
|
|
||||||
# Free the seat for the activated license
|
# Free the seat for the activated license
|
||||||
& "c:\steps\return_license.ps1"
|
& "c:\steps\return_license.ps1"
|
||||||
Start-Sleep 3
|
|
||||||
Get-Process
|
|
||||||
|
|
||||||
# Kill the regsvr process
|
# Kill the regsvr process
|
||||||
Get-Process -Name regsvr32 | ForEach-Object { Stop-Process -Id $_.Id -Force }
|
Get-Process -Name regsvr32 | ForEach-Object { Stop-Process -Id $_.Id -Force }
|
||||||
Start-Sleep 3
|
|
||||||
Get-Process
|
|
||||||
|
Loading…
Reference in New Issue
Block a user