@@ -1492,37 +1492,34 @@ function Start-UnityEditor {
1492
1492
$unityArgs = $sharedArgs | ForEach-Object { $_ }
1493
1493
if ( $instanceArgs [$i ] ) { $unityArgs += $instanceArgs [$i ] }
1494
1494
1495
- $setProcessArgs = @ {
1496
- ' FilePath' = $editor ;
1497
- ' PassThru' = $true ;
1498
- ' ErrorAction' = ' Stop' ;
1499
- ' RedirectStandardOutput' = New-TemporaryFile ;
1500
- ' RedirectStandardError' = New-TemporaryFile ;
1501
- }
1502
-
1503
- if ($Wait ) { $setProcessArgs [' Wait' ] = $true }
1504
-
1505
- Write-Verbose " Redirecting standard output to $ ( $setProcessArgs [' RedirectStandardOutput' ]) "
1506
- Write-Verbose " Redirecting standard error to $ ( $setProcessArgs [' RedirectStandardError' ]) "
1507
-
1508
1495
$actionString = " $editor $unityArgs "
1509
- if ( $Credential ) { $actionString += " -password (hidden)" }
1510
- if ( $Serial ) { $actionString += " -serial (hidden)" }
1496
+ if ( $Credential ) { $actionString += " -password (hidden)" }
1497
+ if ( $Serial ) { $actionString += " -serial (hidden)" }
1511
1498
1512
- if (-not $PSCmdlet.ShouldProcess ($actionString , " Start- Process" )) {
1499
+ if (-not $PSCmdlet.ShouldProcess ($actionString , " System.Diagnostics. Process.Start() " )) {
1513
1500
continue
1514
1501
}
1515
1502
1516
1503
# Defered till after potential display by ShouldProcess
1517
1504
if ( $Credential ) { $unityArgs += ' -password' , $Credential.GetNetworkCredential ().Password }
1518
1505
if ( $Serial ) { $unityArgs += ' -serial' , [System.Net.NetworkCredential ]::new($null , $Serial ).Password }
1519
1506
1520
- if ($unityArgs -and $unityArgs.Length -gt 0 ) {
1521
- $setProcessArgs [' ArgumentList' ] = $unityArgs
1522
- }
1523
-
1524
- $process = Start-Process @setProcessArgs
1507
+ # We've experienced issues with Start-Process -Wait and redirecting
1508
+ # output so we're using the Process class directly now.
1509
+ $process = New-Object System.Diagnostics.Process
1510
+ $process.StartInfo.Filename = $editor
1511
+ $process.StartInfo.Arguments = $unityArgs
1512
+ $process.StartInfo.RedirectStandardOutput = $true
1513
+ $process.StartInfo.RedirectStandardError = $true
1514
+ $process.StartInfo.UseShellExecute = $false
1515
+ $process.StartInfo.CreateNoWindow = $true
1516
+ $process.StartInfo.WorkingDirectory = $PWD
1517
+ $process.StartInfo.WindowStyle = [System.Diagnostics.ProcessWindowStyle ]::Hidden
1518
+ $process.Start () | Out-Null
1519
+
1525
1520
if ( $Wait ) {
1521
+ $process.WaitForExit ()
1522
+
1526
1523
if ( $LogFile -and (Test-Path $LogFile - Type Leaf) ) {
1527
1524
# Note that Unity sometimes returns a success ExitCode despite the presence of errors, but we want
1528
1525
# to make sure that we flag such errors.
0 commit comments