Skip to content

Commit 0f40282

Browse files
authored
Merge pull request #103 from jwittner/fix/exitCodeCheck
Wait in the Start-Process call.
2 parents f09d79c + 5d9b4fc commit 0f40282

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

UnitySetup/UnitySetup.psm1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class UnitySetupInstance {
7171
[UnitySetupComponent]::StandardAssets = , [io.path]::Combine("$Path", "Editor\Standard Assets");
7272
[UnitySetupComponent]::Windows_IL2CPP = , [io.path]::Combine("$playbackEnginePath", "windowsstandalonesupport\Variations\win32_development_il2cpp");
7373
[UnitySetupComponent]::Metro = [io.path]::Combine("$playbackEnginePath", "MetroSupport\Templates\UWP_.NET_D3D"),
74-
[io.path]::Combine("$playbackEnginePath", "MetroSupport\Templates\UWP_D3D");
74+
[io.path]::Combine("$playbackEnginePath", "MetroSupport\Templates\UWP_D3D");
7575
[UnitySetupComponent]::UWP_IL2CPP = , [io.path]::Combine("$playbackEnginePath", "MetroSupport\Templates\UWP_IL2CPP_D3D");
7676
[UnitySetupComponent]::Linux = , [io.path]::Combine("$playbackEnginePath", "LinuxStandaloneSupport");
7777
[UnitySetupComponent]::Mac = , [io.path]::Combine("$playbackEnginePath", "MacStandaloneSupport");
@@ -289,7 +289,7 @@ function Find-UnitySetupInstaller {
289289
[UnitySetupComponent]::Facebook = , "TargetSupportInstaller/UnitySetup-Facebook-Games-Support-for-Editor-$Version.exe";
290290
[UnitySetupComponent]::Linux = , "TargetSupportInstaller/UnitySetup-Linux-Support-for-Editor-$Version.exe";
291291
[UnitySetupComponent]::Mac = "TargetSupportInstaller/UnitySetup-Mac-Support-for-Editor-$Version.exe",
292-
"TargetSupportInstaller/UnitySetup-Mac-Mono-Support-for-Editor-$Version.exe";
292+
"TargetSupportInstaller/UnitySetup-Mac-Mono-Support-for-Editor-$Version.exe";
293293
[UnitySetupComponent]::Vuforia = , "TargetSupportInstaller/UnitySetup-Vuforia-AR-Support-for-Editor-$Version.exe";
294294
[UnitySetupComponent]::WebGL = , "TargetSupportInstaller/UnitySetup-WebGL-Support-for-Editor-$Version.exe";
295295
[UnitySetupComponent]::Windows_IL2CPP = , "TargetSupportInstaller/UnitySetup-Windows-IL2CPP-Support-for-Editor-$Version.exe";
@@ -480,6 +480,7 @@ function Install-UnitySetupInstance {
480480
'FilePath' = $installer;
481481
'ArgumentList' = @("/S", "/D=$destination");
482482
'PassThru' = $true;
483+
'Wait' = $true;
483484
}
484485

485486
if ($Verb) {
@@ -488,9 +489,7 @@ function Install-UnitySetupInstance {
488489

489490
Write-Verbose "$(Get-Date): Installing $installer to $destination."
490491
$process = Start-Process @startProcessArgs
491-
if( $process ) {
492-
$process.WaitForExit()
493-
492+
if ( $process ) {
494493
if ( $process.ExitCode -ne 0) {
495494
Write-Error "$(Get-Date): Failed with exit code: $($process.ExitCode)"
496495
}
@@ -838,7 +837,7 @@ function Start-UnityEditor {
838837
$sharedArgs = @()
839838
if ( $AcceptAPIUpdate ) {
840839
$sharedArgs += '-accept-apiupdate'
841-
if( -not $PSBoundParameters.ContainsKey('BatchMode')) { $BatchMode = $true }
840+
if ( -not $PSBoundParameters.ContainsKey('BatchMode')) { $BatchMode = $true }
842841
}
843842

844843
if ( $CreateProject ) { $sharedArgs += "-createProject", $CreateProject }
@@ -921,6 +920,8 @@ function Start-UnityEditor {
921920
'RedirectStandardError' = New-TemporaryFile;
922921
}
923922

923+
if ($Wait) { $setProcessArgs['Wait'] = $true }
924+
924925
Write-Verbose "Redirecting standard output to $($setProcessArgs['RedirectStandardOutput'])"
925926
Write-Verbose "Redirecting standard error to $($setProcessArgs['RedirectStandardError'])"
926927

@@ -934,13 +935,12 @@ function Start-UnityEditor {
934935

935936
$process = Start-Process @setProcessArgs
936937
if ( $Wait ) {
937-
$process.WaitForExit();
938938
if ( $process.ExitCode -ne 0 ) {
939939
if ( $LogFile -and (Test-Path $LogFile -Type Leaf) ) {
940940
Get-Content $LogFile | ForEach-Object { Write-Information -MessageData $_ -Tags 'Logs' }
941941
}
942942

943-
Write-Error "Unity quit with non-zero exit code"
943+
Write-Error "Unity quit with non-zero exit code: $($process.ExitCode)"
944944
}
945945
}
946946

0 commit comments

Comments
 (0)