Skip to content

Commit

Permalink
Fix possible hang
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewKahr committed Dec 11, 2023
1 parent 7afd913 commit 8af95d8
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 23 deletions.
46 changes: 34 additions & 12 deletions dist/platforms/windows/activate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,40 @@ if ( ($null -ne ${env:UNITY_SERIAL}) -and ($null -ne ${env:UNITY_EMAIL}) -and ($
#
Write-Output "Requesting activation"

$ACTIVATION_OUTPUT = Start-Process -NoNewWindow -Wait -PassThru "$Env:UNITY_PATH/Editor/Unity.exe" `
-ArgumentList `
"-batchmode `
-quit `
-nographics `
-username $Env:UNITY_EMAIL `
-password $Env:UNITY_PASSWORD `
-serial $Env:UNITY_SERIAL `
-projectPath c:/BlankProject `
-logfile -"

$ACTIVATION_EXIT_CODE = $ACTIVATION_OUTPUT.ExitCode
$ACTIVATION_OUTPUT = Start-Process -FilePath "$Env:UNITY_PATH/Editor/Unity.exe" `
-NoNewWindow `
-PassThru `
-ArgumentList "-batchmode `
-quit `
-nographics `
-username $Env:UNITY_EMAIL `
-password $Env:UNITY_PASSWORD `
-serial $Env:UNITY_SERIAL `
-projectPath c:/BlankProject `
-logfile -"

# Cache the handle so exit code works properly
# https://stackoverflow.com/questions/10262231/obtaining-exitcode-using-start-process-and-waitforexit-instead-of-wait
$unityHandle = $ACTIVATION_OUTPUT.Handle

while ($true) {
if ($ACTIVATION_OUTPUT.HasExited) {
$ACTIVATION_EXIT_CODE = $ACTIVATION_OUTPUT.ExitCode

# Display results
if ($ACTIVATION_EXIT_CODE -eq 0)
{
Write-Output "Activation Succeeded"
} else
{
Write-Output "Activation failed, with exit code $ACTIVATION_EXIT_CODE"
}

break
}

Start-Sleep -Seconds 3
}
}
else
{
Expand Down
48 changes: 37 additions & 11 deletions dist/platforms/windows/return_license.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,47 @@ Write-Output "# Return License #"
Write-Output "###########################"
Write-Output ""

if ($null -ne ${env:UNITY_SERIAL})
if (($null -ne ${env:UNITY_SERIAL}) -and ($null -ne ${env:UNITY_EMAIL}) -and ($null -ne ${env:UNITY_PASSWORD}))
{
#
# SERIAL LICENSE MODE
#
# This will return the license that is currently in use.
#
$RETURN_OUTPUT = Start-Process -NoNewWindow -Wait -PassThru "$Env:UNITY_PATH/Editor/Unity.exe" `
-ArgumentList `
"-batchmode `
-quit `
-nographics `
-username $Env:UNITY_EMAIL `
-password $Env:UNITY_PASSWORD `
-returnlicense `
-projectPath c:/BlankProject `
-logfile -"
$RETURN_LICENSE_OUTPUT = Start-Process -FilePath "$Env:UNITY_PATH/Editor/Unity.exe" `
-NoNewWindow `
-PassThru `
-ArgumentList "-batchmode `
-quit `
-nographics `
-username $Env:UNITY_EMAIL `
-password $Env:UNITY_PASSWORD `
-returnlicense `
-projectPath c:/BlankProject `
-logfile -"

# Cache the handle so exit code works properly
# https://stackoverflow.com/questions/10262231/obtaining-exitcode-using-start-process-and-waitforexit-instead-of-wait
$unityHandle = $RETURN_LICENSE_OUTPUT.Handle

while ($true) {
if ($RETURN_LICENSE_OUTPUT.HasExited) {
$RETURN_LICENSE_EXIT_CODE = $RETURN_LICENSE_OUTPUT.ExitCode

# Display results
if ($RETURN_LICENSE_EXIT_CODE -eq 0)
{
Write-Output "License Return Succeeded"
} else
{
Write-Output "License Return failed, with exit code $RETURN_LICENSE_EXIT_CODE"
Write-Output "::warning ::License Return failed! If this is a Pro License you might need to manually `
free the seat in your Unity admin panel or you might run out of seats to activate with."
}

break
}

Start-Sleep -Seconds 3
}
}

0 comments on commit 8af95d8

Please sign in to comment.