@@ -73,14 +73,14 @@ class UnitySetupInstance {
73
73
$this.Components = [UnitySetupComponent ]::Windows
74
74
$playbackEnginePath = [io.path ]::Combine(" $Path " , " Editor\Data\PlaybackEngines" );
75
75
@ {
76
- [UnitySetupComponent ]::Documentation = , [io.path ]::Combine(" $Path " , " Editor\Data\Documentation" );
76
+ [UnitySetupComponent ]::Documentation = , [io.path ]::Combine(" $Path " , " Editor\Data\Documentation" );
77
77
[UnitySetupComponent ]::StandardAssets = , [io.path ]::Combine(" $Path " , " Editor\Standard Assets" );
78
78
[UnitySetupComponent ]::Windows_IL2CPP = , [io.path ]::Combine(" $playbackEnginePath " , " windowsstandalonesupport\Variations\win32_development_il2cpp" );
79
- [UnitySetupComponent ]::UWP = [io.path ]::Combine(" $playbackEnginePath " , " MetroSupport\Templates\UWP_.NET_D3D" ),
79
+ [UnitySetupComponent ]::UWP = [io.path ]::Combine(" $playbackEnginePath " , " MetroSupport\Templates\UWP_.NET_D3D" ),
80
80
[io.path ]::Combine(" $playbackEnginePath " , " MetroSupport\Templates\UWP_D3D" );
81
- [UnitySetupComponent ]::UWP_IL2CPP = , [io.path ]::Combine(" $playbackEnginePath " , " MetroSupport\Templates\UWP_IL2CPP_D3D" );
82
- [UnitySetupComponent ]::Linux = , [io.path ]::Combine(" $playbackEnginePath " , " LinuxStandaloneSupport" );
83
- [UnitySetupComponent ]::Mac = , [io.path ]::Combine(" $playbackEnginePath " , " MacStandaloneSupport" );
81
+ [UnitySetupComponent ]::UWP_IL2CPP = , [io.path ]::Combine(" $playbackEnginePath " , " MetroSupport\Templates\UWP_IL2CPP_D3D" );
82
+ [UnitySetupComponent ]::Linux = , [io.path ]::Combine(" $playbackEnginePath " , " LinuxStandaloneSupport" );
83
+ [UnitySetupComponent ]::Mac = , [io.path ]::Combine(" $playbackEnginePath " , " MacStandaloneSupport" );
84
84
}
85
85
}
86
86
([OperatingSystem ]::Linux) {
@@ -92,10 +92,10 @@ class UnitySetupInstance {
92
92
$this.Components = [UnitySetupComponent ]::Mac
93
93
$playbackEnginePath = [io.path ]::Combine(" $Path " , " PlaybackEngines" );
94
94
@ {
95
- [UnitySetupComponent ]::Documentation = , [io.path ]::Combine(" $Path " , " Documentation" );
95
+ [UnitySetupComponent ]::Documentation = , [io.path ]::Combine(" $Path " , " Documentation" );
96
96
[UnitySetupComponent ]::StandardAssets = , [io.path ]::Combine(" $Path " , " Standard Assets" );
97
- [UnitySetupComponent ]::Windows = , [io.path ]::Combine(" $playbackEnginePath " , " WindowsStandaloneSupport" );
98
- [UnitySetupComponent ]::Linux = , [io.path ]::Combine(" $playbackEnginePath " , " LinuxStandaloneSupport" );
97
+ [UnitySetupComponent ]::Windows = , [io.path ]::Combine(" $playbackEnginePath " , " WindowsStandaloneSupport" );
98
+ [UnitySetupComponent ]::Linux = , [io.path ]::Combine(" $playbackEnginePath " , " LinuxStandaloneSupport" );
99
99
}
100
100
}
101
101
}
@@ -309,18 +309,18 @@ function Find-UnitySetupInstaller {
309
309
)
310
310
311
311
$installerTemplates = @ {
312
- [UnitySetupComponent ]::UWP = " $targetSupport /UnitySetup-UWP-.NET-Support-for-Editor-$Version .$installerExtension " ,
313
- " $targetSupport /UnitySetup-Metro-Support-for-Editor-$Version .$installerExtension " ;
314
- [UnitySetupComponent ]::UWP_IL2CPP = , " $targetSupport /UnitySetup-UWP-IL2CPP-Support-for-Editor-$Version .$installerExtension " ;
315
- [UnitySetupComponent ]::Android = , " $targetSupport /UnitySetup-Android-Support-for-Editor-$Version .$installerExtension " ;
316
- [UnitySetupComponent ]::iOS = , " $targetSupport /UnitySetup-iOS-Support-for-Editor-$Version .$installerExtension " ;
317
- [UnitySetupComponent ]::AppleTV = , " $targetSupport /UnitySetup-AppleTV-Support-for-Editor-$Version .$installerExtension " ;
318
- [UnitySetupComponent ]::Facebook = , " $targetSupport /UnitySetup-Facebook-Games-Support-for-Editor-$Version .$installerExtension " ;
319
- [UnitySetupComponent ]::Linux = , " $targetSupport /UnitySetup-Linux-Support-for-Editor-$Version .$installerExtension " ;
320
- [UnitySetupComponent ]::Mac = " $targetSupport /UnitySetup-Mac-Support-for-Editor-$Version .$installerExtension " ,
312
+ [UnitySetupComponent ]::UWP = " $targetSupport /UnitySetup-UWP-.NET-Support-for-Editor-$Version .$installerExtension " ,
313
+ " $targetSupport /UnitySetup-Metro-Support-for-Editor-$Version .$installerExtension " ;
314
+ [UnitySetupComponent ]::UWP_IL2CPP = , " $targetSupport /UnitySetup-UWP-IL2CPP-Support-for-Editor-$Version .$installerExtension " ;
315
+ [UnitySetupComponent ]::Android = , " $targetSupport /UnitySetup-Android-Support-for-Editor-$Version .$installerExtension " ;
316
+ [UnitySetupComponent ]::iOS = , " $targetSupport /UnitySetup-iOS-Support-for-Editor-$Version .$installerExtension " ;
317
+ [UnitySetupComponent ]::AppleTV = , " $targetSupport /UnitySetup-AppleTV-Support-for-Editor-$Version .$installerExtension " ;
318
+ [UnitySetupComponent ]::Facebook = , " $targetSupport /UnitySetup-Facebook-Games-Support-for-Editor-$Version .$installerExtension " ;
319
+ [UnitySetupComponent ]::Linux = , " $targetSupport /UnitySetup-Linux-Support-for-Editor-$Version .$installerExtension " ;
320
+ [UnitySetupComponent ]::Mac = " $targetSupport /UnitySetup-Mac-Support-for-Editor-$Version .$installerExtension " ,
321
321
" $targetSupport /UnitySetup-Mac-Mono-Support-for-Editor-$Version .$installerExtension " ;
322
- [UnitySetupComponent ]::Vuforia = , " $targetSupport /UnitySetup-Vuforia-AR-Support-for-Editor-$Version .$installerExtension " ;
323
- [UnitySetupComponent ]::WebGL = , " $targetSupport /UnitySetup-WebGL-Support-for-Editor-$Version .$installerExtension " ;
322
+ [UnitySetupComponent ]::Vuforia = , " $targetSupport /UnitySetup-Vuforia-AR-Support-for-Editor-$Version .$installerExtension " ;
323
+ [UnitySetupComponent ]::WebGL = , " $targetSupport /UnitySetup-WebGL-Support-for-Editor-$Version .$installerExtension " ;
324
324
[UnitySetupComponent ]::Windows_IL2CPP = , " $targetSupport /UnitySetup-Windows-IL2CPP-Support-for-Editor-$Version .$installerExtension " ;
325
325
}
326
326
@@ -434,10 +434,10 @@ function Find-UnitySetupInstaller {
434
434
}
435
435
$result = New-Object UnitySetupInstaller - Property @ {
436
436
' ComponentType' = $_ ;
437
- ' Version' = $Version ;
438
- ' DownloadUrl' = $endpoint ;
439
- ' Length' = $installerLength ;
440
- ' LastModified' = $lastModified ;
437
+ ' Version' = $Version ;
438
+ ' DownloadUrl' = $endpoint ;
439
+ ' Length' = $installerLength ;
440
+ ' LastModified' = $lastModified ;
441
441
}
442
442
443
443
break
@@ -540,13 +540,13 @@ function Select-UnitySetupInstaller {
540
540
}
541
541
542
542
filter Format-Bytes {
543
- return " {0:N2} {1}" -f $ (
544
- if ($_ -lt 1 kb ) { $_ , ' Bytes' }
545
- elseif ($_ -lt 1 mb ) { ($_ / 1 kb ), ' KB' }
546
- elseif ($_ -lt 1 gb ) { ($_ / 1 mb ), ' MB' }
547
- elseif ($_ -lt 1 tb ) { ($_ / 1 gb ), ' GB' }
548
- elseif ($_ -lt 1 pb ) { ($_ / 1 tb ), ' TB' }
549
- else { ($_ / 1 pb ), ' PB' }
543
+ return " {0:N2} {1}" -f $ (
544
+ if ($_ -lt 1 kb ) { $_ , ' Bytes' }
545
+ elseif ($_ -lt 1 mb ) { ($_ / 1 kb ), ' KB' }
546
+ elseif ($_ -lt 1 gb ) { ($_ / 1 mb ), ' MB' }
547
+ elseif ($_ -lt 1 tb ) { ($_ / 1 gb ), ' GB' }
548
+ elseif ($_ -lt 1 pb ) { ($_ / 1 tb ), ' TB' }
549
+ else { ($_ / 1 pb ), ' PB' }
550
550
)
551
551
}
552
552
@@ -564,13 +564,13 @@ function Format-BitsPerSecond {
564
564
}
565
565
# Convert from bytes to bits
566
566
$Bits = ($Bytes * 8 ) / $Seconds
567
- return " {0:N2} {1}" -f $ (
568
- if ($Bits -lt 1 kb ) { $Bits , ' Bps' }
569
- elseif ($Bits -lt 1 mb ) { ($Bits / 1 kb ), ' Kbps' }
570
- elseif ($Bits -lt 1 gb ) { ($Bits / 1 mb ), ' Mbps' }
571
- elseif ($Bits -lt 1 tb ) { ($Bits / 1 gb ), ' Gbps' }
572
- elseif ($Bits -lt 1 pb ) { ($Bits / 1 tb ), ' Tbps' }
573
- else { ($Bits / 1 pb ), ' Pbps' }
567
+ return " {0:N2} {1}" -f $ (
568
+ if ($Bits -lt 1 kb ) { $Bits , ' Bps' }
569
+ elseif ($Bits -lt 1 mb ) { ($Bits / 1 kb ), ' Kbps' }
570
+ elseif ($Bits -lt 1 gb ) { ($Bits / 1 mb ), ' Mbps' }
571
+ elseif ($Bits -lt 1 tb ) { ($Bits / 1 gb ), ' Gbps' }
572
+ elseif ($Bits -lt 1 pb ) { ($Bits / 1 tb ), ' Tbps' }
573
+ else { ($Bits / 1 pb ), ' Pbps' }
574
574
)
575
575
}
576
576
@@ -638,7 +638,7 @@ function Request-UnitySetupInstaller {
638
638
639
639
$resource = New-Object UnitySetupResource - Property @ {
640
640
' ComponentType' = $_.ComponentType
641
- ' Path' = $destination
641
+ ' Path' = $destination
642
642
}
643
643
$downloads += , $resource
644
644
return
@@ -655,15 +655,15 @@ function Request-UnitySetupInstaller {
655
655
++ $downloadIndex
656
656
$global :downloadData [$installerFileName ] = New-Object PSObject - Property @ {
657
657
installerFileName = $installerFileName
658
- startTime = Get-Date
659
- totalBytes = $_.Length
660
- receivedBytes = 0
661
- isDownloaded = $false
662
- destination = $destination
663
- lastModified = $_.LastModified
664
- componentType = $_.ComponentType
665
- webClient = $webClient
666
- downloadIndex = $downloadIndex
658
+ startTime = Get-Date
659
+ totalBytes = $_.Length
660
+ receivedBytes = 0
661
+ isDownloaded = $false
662
+ destination = $destination
663
+ lastModified = $_.LastModified
664
+ componentType = $_.ComponentType
665
+ webClient = $webClient
666
+ downloadIndex = $downloadIndex
667
667
}
668
668
669
669
# Register to events for showing progress of file download.
@@ -674,8 +674,7 @@ function Request-UnitySetupInstaller {
674
674
$global :downloadData [$event.MessageData ].isDownloaded = $true
675
675
} | Out-Null
676
676
677
- try
678
- {
677
+ try {
679
678
Write-Verbose " Downloading $ ( $_.DownloadUrl ) to $destination "
680
679
$webClient.DownloadFileAsync ($_.DownloadUrl , $destination )
681
680
}
@@ -720,7 +719,7 @@ function Request-UnitySetupInstaller {
720
719
721
720
$resource = New-Object UnitySetupResource - Property @ {
722
721
' ComponentType' = $data.componentType
723
- ' Path' = $data.destination
722
+ ' Path' = $data.destination
724
723
}
725
724
$downloads += , $resource
726
725
return
@@ -789,10 +788,10 @@ function Install-UnitySetupPackage {
789
788
switch ($currentOS ) {
790
789
([OperatingSystem ]::Windows) {
791
790
$startProcessArgs = @ {
792
- ' FilePath' = $Package.Path ;
791
+ ' FilePath' = $Package.Path ;
793
792
' ArgumentList' = @ (" /S" , " /D=$Destination " );
794
- ' PassThru' = $true ;
795
- ' Wait' = $true ;
793
+ ' PassThru' = $true ;
794
+ ' Wait' = $true ;
796
795
}
797
796
}
798
797
([OperatingSystem ]::Linux) {
@@ -802,10 +801,10 @@ function Install-UnitySetupPackage {
802
801
# Note that $Destination has to be a disk path.
803
802
# sudo installer -package $Package.Path -target /
804
803
$startProcessArgs = @ {
805
- ' FilePath' = ' sudo' ;
804
+ ' FilePath' = ' sudo' ;
806
805
' ArgumentList' = @ (" installer" , " -package" , $Package.Path , " -target" , $Destination );
807
- ' PassThru' = $true ;
808
- ' Wait' = $true ;
806
+ ' PassThru' = $true ;
807
+ ' Wait' = $true ;
809
808
}
810
809
}
811
810
}
@@ -985,8 +984,7 @@ function Install-UnitySetupInstance {
985
984
# Move the install from the sparse bundle disk to the install directory.
986
985
if ($currentOS -eq [OperatingSystem ]::Mac) {
987
986
# rsync does not recursively create the directory path.
988
- if (-not (Test-Path $installPath - PathType Container))
989
- {
987
+ if (-not (Test-Path $installPath - PathType Container)) {
990
988
Write-Verbose " Creating directory $installPath ."
991
989
New-Item $installPath - ItemType Directory - ErrorAction Stop | Out-Null
992
990
}
@@ -1039,10 +1037,10 @@ function Uninstall-UnitySetupInstance {
1039
1037
}
1040
1038
1041
1039
$startProcessArgs = @ {
1042
- ' FilePath' = $uninstaller ;
1043
- ' PassThru' = $true ;
1044
- ' Wait' = $true ;
1045
- ' ErrorAction' = ' Stop' ;
1040
+ ' FilePath' = $uninstaller ;
1041
+ ' PassThru' = $true ;
1042
+ ' Wait' = $true ;
1043
+ ' ErrorAction' = ' Stop' ;
1046
1044
' ArgumentList' = @ (" /S" );
1047
1045
}
1048
1046
@@ -1186,10 +1184,10 @@ function Get-UnityProjectInstance {
1186
1184
)
1187
1185
1188
1186
$args = @ {
1189
- ' Path' = $BasePath ;
1190
- ' Filter' = ' ProjectSettings' ;
1187
+ ' Path' = $BasePath ;
1188
+ ' Filter' = ' ProjectSettings' ;
1191
1189
' ErrorAction' = ' Ignore' ;
1192
- ' Directory' = $true ;
1190
+ ' Directory' = $true ;
1193
1191
}
1194
1192
1195
1193
if ( $Recurse ) {
@@ -1500,37 +1498,34 @@ function Start-UnityEditor {
1500
1498
$unityArgs = $sharedArgs | ForEach-Object { $_ }
1501
1499
if ( $instanceArgs [$i ] ) { $unityArgs += $instanceArgs [$i ] }
1502
1500
1503
- $setProcessArgs = @ {
1504
- ' FilePath' = $editor ;
1505
- ' PassThru' = $true ;
1506
- ' ErrorAction' = ' Stop' ;
1507
- ' RedirectStandardOutput' = New-TemporaryFile ;
1508
- ' RedirectStandardError' = New-TemporaryFile ;
1509
- }
1510
-
1511
- if ($Wait ) { $setProcessArgs [' Wait' ] = $true }
1512
-
1513
- Write-Verbose " Redirecting standard output to $ ( $setProcessArgs [' RedirectStandardOutput' ]) "
1514
- Write-Verbose " Redirecting standard error to $ ( $setProcessArgs [' RedirectStandardError' ]) "
1515
-
1516
1501
$actionString = " $editor $unityArgs "
1517
- if ( $Credential ) { $actionString += " -password (hidden)" }
1518
- if ( $Serial ) { $actionString += " -serial (hidden)" }
1502
+ if ( $Credential ) { $actionString += " -password (hidden)" }
1503
+ if ( $Serial ) { $actionString += " -serial (hidden)" }
1519
1504
1520
- if (-not $PSCmdlet.ShouldProcess ($actionString , " Start- Process" )) {
1505
+ if (-not $PSCmdlet.ShouldProcess ($actionString , " System.Diagnostics. Process.Start() " )) {
1521
1506
continue
1522
1507
}
1523
1508
1524
1509
# Defered till after potential display by ShouldProcess
1525
1510
if ( $Credential ) { $unityArgs += ' -password' , $Credential.GetNetworkCredential ().Password }
1526
1511
if ( $Serial ) { $unityArgs += ' -serial' , [System.Net.NetworkCredential ]::new($null , $Serial ).Password }
1527
1512
1528
- if ($unityArgs -and $unityArgs.Length -gt 0 ) {
1529
- $setProcessArgs [' ArgumentList' ] = $unityArgs
1530
- }
1531
-
1532
- $process = Start-Process @setProcessArgs
1513
+ # We've experienced issues with Start-Process -Wait and redirecting
1514
+ # output so we're using the Process class directly now.
1515
+ $process = New-Object System.Diagnostics.Process
1516
+ $process.StartInfo.Filename = $editor
1517
+ $process.StartInfo.Arguments = $unityArgs
1518
+ $process.StartInfo.RedirectStandardOutput = $true
1519
+ $process.StartInfo.RedirectStandardError = $true
1520
+ $process.StartInfo.UseShellExecute = $false
1521
+ $process.StartInfo.CreateNoWindow = $true
1522
+ $process.StartInfo.WorkingDirectory = $PWD
1523
+ $process.StartInfo.WindowStyle = [System.Diagnostics.ProcessWindowStyle ]::Hidden
1524
+ $process.Start () | Out-Null
1525
+
1533
1526
if ( $Wait ) {
1527
+ $process.WaitForExit ()
1528
+
1534
1529
if ( $LogFile -and (Test-Path $LogFile - Type Leaf) ) {
1535
1530
# Note that Unity sometimes returns a success ExitCode despite the presence of errors, but we want
1536
1531
# to make sure that we flag such errors.
@@ -1593,7 +1588,7 @@ function Get-IsUnityError {
1593
1588
function ConvertTo-DateTime {
1594
1589
param ([string ] $Text )
1595
1590
1596
- if ( -not $text -or $text.Length -eq 0 ) { [DateTime ]::MaxValue }
1591
+ if ( -not $text -or $text.Length -eq 0 ) { [DateTime ]::MaxValue }
1597
1592
else { [DateTime ]$Text }
1598
1593
}
1599
1594
@@ -1605,10 +1600,9 @@ function ConvertTo-DateTime {
1605
1600
. EXAMPLE
1606
1601
Get-UnityLicense
1607
1602
#>
1608
- function Get-UnityLicense
1609
- {
1603
+ function Get-UnityLicense {
1610
1604
[CmdletBinding ()]
1611
- [Diagnostics.CodeAnalysis.SuppressMessageAttribute (" PSAvoidUsingConvertToSecureStringWithPlainText" , " " , Justification= " Used to convert discovered plaintext serials into secure strings." )]
1605
+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute (" PSAvoidUsingConvertToSecureStringWithPlainText" , " " , Justification = " Used to convert discovered plaintext serials into secure strings." )]
1612
1606
param ([SecureString ]$Serial )
1613
1607
1614
1608
$licenseFiles = Get-ChildItem " C:\ProgramData\Unity\Unity_*.ulf" - ErrorAction ' SilentlyContinue'
@@ -1619,18 +1613,18 @@ function Get-UnityLicense
1619
1613
1620
1614
# The first four bytes look like a count so skip that to pull out the serial string
1621
1615
$licenseSerial = [String ]::new($devBytes [4 .. ($devBytes.Length - 1 )])
1622
- if ( $Serial -and [System.Net.NetworkCredential ]::new($null , $Serial ).Password -ne $licenseSerial ) { continue ; }
1616
+ if ( $Serial -and [System.Net.NetworkCredential ]::new($null , $Serial ).Password -ne $licenseSerial ) { continue ; }
1623
1617
1624
1618
$license = $doc.root.License
1625
1619
[PSCustomObject ]@ {
1626
1620
' LicenseVersion' = $license.LicenseVersion.Value
1627
- ' Serial' = ConvertTo-SecureString $licenseSerial - AsPlainText - Force
1628
- ' UnityVersion' = [UnityVersion ]$license.ClientProvidedVersion.Value
1629
- ' DisplaySerial' = $license.SerialMasked.Value
1621
+ ' Serial' = ConvertTo-SecureString $licenseSerial - AsPlainText - Force
1622
+ ' UnityVersion' = [UnityVersion ]$license.ClientProvidedVersion.Value
1623
+ ' DisplaySerial' = $license.SerialMasked.Value
1630
1624
' ActivationDate' = ConvertTo-DateTime $license.InitialActivationDate.Value
1631
- ' StartDate' = ConvertTo-DateTime $license.StartDate.Value
1632
- ' StopDate' = ConvertTo-DateTime $license.StopDate.Value
1633
- ' UpdateDate' = ConvertTo-DateTime $license.UpdateDate.Value
1625
+ ' StartDate' = ConvertTo-DateTime $license.StartDate.Value
1626
+ ' StopDate' = ConvertTo-DateTime $license.StopDate.Value
1627
+ ' UpdateDate' = ConvertTo-DateTime $license.UpdateDate.Value
1634
1628
}
1635
1629
}
1636
1630
}
0 commit comments