Skip to content

Commit ba790c9

Browse files
authored
Merge pull request #91 from jwittner/fix/unityInstallSpam
No more write-host for Install-UnitySetupInstance
2 parents b72c4df + 692c6f9 commit ba790c9

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

UnitySetup/UnitySetup.psm1

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ function Find-UnitySetupInstaller {
315315
#>
316316
function Install-UnitySetupInstance {
317317
[CmdletBinding()]
318-
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Scope = 'Function')]
319318
param(
320319
[parameter(ValueFromPipeline = $true)]
321320
[UnitySetupInstaller[]] $Installers,
@@ -377,34 +376,31 @@ function Install-UnitySetupInstance {
377376
Start-BitsTransfer -Source $downloadSource -Destination $downloadDest
378377
}
379378

380-
$spins = @('|', '/', '-', '\')
381379
for ($i = 0; $i -lt $localInstallers.Length; $i++) {
382380
$installer = $localInstallers[$i]
383381
$destination = $localDestinations[$i]
384382

385383
$startProcessArgs = @{
386384
'FilePath' = $installer;
387-
'ArgumentList' = @("/S", "/D=$($localDestinations[$i])");
385+
'ArgumentList' = @("/S", "/D=$destination");
388386
'PassThru' = $true;
389387
}
390388

391389
if ($Verb) {
392390
$startProcessArgs['Verb'] = $Verb
393391
}
394392

395-
$spinnerIndex = 0
393+
Write-Verbose "$(Get-Date): Installing $installer to $destination."
396394
$process = Start-Process @startProcessArgs
397-
while (!$process.HasExited) {
398-
Write-Host "`rInstalling $installer to $destination - $($spins[$spinnerIndex++ % $spins.Length])" -NoNewline
399-
Start-Sleep -Milliseconds 100
400-
}
395+
if( $process ) {
396+
$process.WaitForExit()
401397

402-
if ( $process.ExitCode -ne 0) {
403-
Write-Host "`bFailed."
404-
Write-Error "Installing $installer failed with exit code: $($process.ExitCode)"
405-
}
406-
else {
407-
Write-Host "`bSucceeded."
398+
if ( $process.ExitCode -ne 0) {
399+
Write-Error "$(Get-Date): Failed with exit code: $($process.ExitCode)"
400+
}
401+
else {
402+
Write-Verbose "$(Get-Date): Succeeded."
403+
}
408404
}
409405
}
410406
}

0 commit comments

Comments
 (0)