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