Skip to content

Commit e428577

Browse files
authored
Merge branch 'develop' into dev-macil2cpp
2 parents 2394ed8 + 0881fff commit e428577

File tree

1 file changed

+93
-99
lines changed

1 file changed

+93
-99
lines changed

UnitySetup/UnitySetup.psm1

Lines changed: 93 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ class UnitySetupInstance {
7474
$this.Components = [UnitySetupComponent]::Windows
7575
$playbackEnginePath = [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines");
7676
@{
77-
[UnitySetupComponent]::Documentation = , [io.path]::Combine("$Path", "Editor\Data\Documentation");
77+
[UnitySetupComponent]::Documentation = , [io.path]::Combine("$Path", "Editor\Data\Documentation");
7878
[UnitySetupComponent]::StandardAssets = , [io.path]::Combine("$Path", "Editor\Standard Assets");
7979
[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"),
8181
[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");
8585
}
8686
}
8787
([OperatingSystem]::Linux) {
@@ -93,11 +93,11 @@ class UnitySetupInstance {
9393
$this.Components = [UnitySetupComponent]::Mac
9494
$playbackEnginePath = [io.path]::Combine("$Path", "PlaybackEngines");
9595
@{
96-
[UnitySetupComponent]::Documentation = , [io.path]::Combine("$Path", "Documentation");
96+
[UnitySetupComponent]::Documentation = , [io.path]::Combine("$Path", "Documentation");
9797
[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");
101101
}
102102
}
103103
}
@@ -311,19 +311,19 @@ function Find-UnitySetupInstaller {
311311
)
312312

313313
$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",
323323
"$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";
327327
[UnitySetupComponent]::Windows_IL2CPP = , "$targetSupport/UnitySetup-Windows-IL2CPP-Support-for-Editor-$Version.$installerExtension";
328328
}
329329

@@ -437,10 +437,10 @@ function Find-UnitySetupInstaller {
437437
}
438438
$result = New-Object UnitySetupInstaller -Property @{
439439
'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;
444444
}
445445

446446
break
@@ -543,13 +543,13 @@ function Select-UnitySetupInstaller {
543543
}
544544

545545
filter Format-Bytes {
546-
return "{0:N2} {1}" -f $(
547-
if ($_ -lt 1kb) { $_, 'Bytes' }
548-
elseif ($_ -lt 1mb) { ($_/1kb), 'KB' }
549-
elseif ($_ -lt 1gb) { ($_/1mb), 'MB' }
550-
elseif ($_ -lt 1tb) { ($_/1gb), 'GB' }
551-
elseif ($_ -lt 1pb) { ($_/1tb), 'TB' }
552-
else { ($_/1pb), 'PB' }
546+
return "{0:N2} {1}" -f $(
547+
if ($_ -lt 1kb) { $_, 'Bytes' }
548+
elseif ($_ -lt 1mb) { ($_ / 1kb), 'KB' }
549+
elseif ($_ -lt 1gb) { ($_ / 1mb), 'MB' }
550+
elseif ($_ -lt 1tb) { ($_ / 1gb), 'GB' }
551+
elseif ($_ -lt 1pb) { ($_ / 1tb), 'TB' }
552+
else { ($_ / 1pb), 'PB' }
553553
)
554554
}
555555

@@ -567,13 +567,13 @@ function Format-BitsPerSecond {
567567
}
568568
# Convert from bytes to bits
569569
$Bits = ($Bytes * 8) / $Seconds
570-
return "{0:N2} {1}" -f $(
571-
if ($Bits -lt 1kb) { $Bits, 'Bps' }
572-
elseif ($Bits -lt 1mb) { ($Bits/1kb), 'Kbps' }
573-
elseif ($Bits -lt 1gb) { ($Bits/1mb), 'Mbps' }
574-
elseif ($Bits -lt 1tb) { ($Bits/1gb), 'Gbps' }
575-
elseif ($Bits -lt 1pb) { ($Bits/1tb), 'Tbps' }
576-
else { ($Bits/1pb), 'Pbps' }
570+
return "{0:N2} {1}" -f $(
571+
if ($Bits -lt 1kb) { $Bits, 'Bps' }
572+
elseif ($Bits -lt 1mb) { ($Bits / 1kb), 'Kbps' }
573+
elseif ($Bits -lt 1gb) { ($Bits / 1mb), 'Mbps' }
574+
elseif ($Bits -lt 1tb) { ($Bits / 1gb), 'Gbps' }
575+
elseif ($Bits -lt 1pb) { ($Bits / 1tb), 'Tbps' }
576+
else { ($Bits / 1pb), 'Pbps' }
577577
)
578578
}
579579

@@ -641,7 +641,7 @@ function Request-UnitySetupInstaller {
641641

642642
$resource = New-Object UnitySetupResource -Property @{
643643
'ComponentType' = $_.ComponentType
644-
'Path' = $destination
644+
'Path' = $destination
645645
}
646646
$downloads += , $resource
647647
return
@@ -658,15 +658,15 @@ function Request-UnitySetupInstaller {
658658
++$downloadIndex
659659
$global:downloadData[$installerFileName] = New-Object PSObject -Property @{
660660
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
670670
}
671671

672672
# Register to events for showing progress of file download.
@@ -677,8 +677,7 @@ function Request-UnitySetupInstaller {
677677
$global:downloadData[$event.MessageData].isDownloaded = $true
678678
} | Out-Null
679679

680-
try
681-
{
680+
try {
682681
Write-Verbose "Downloading $($_.DownloadUrl) to $destination"
683682
$webClient.DownloadFileAsync($_.DownloadUrl, $destination)
684683
}
@@ -723,7 +722,7 @@ function Request-UnitySetupInstaller {
723722

724723
$resource = New-Object UnitySetupResource -Property @{
725724
'ComponentType' = $data.componentType
726-
'Path' = $data.destination
725+
'Path' = $data.destination
727726
}
728727
$downloads += , $resource
729728
return
@@ -792,10 +791,10 @@ function Install-UnitySetupPackage {
792791
switch ($currentOS) {
793792
([OperatingSystem]::Windows) {
794793
$startProcessArgs = @{
795-
'FilePath' = $Package.Path;
794+
'FilePath' = $Package.Path;
796795
'ArgumentList' = @("/S", "/D=$Destination");
797-
'PassThru' = $true;
798-
'Wait' = $true;
796+
'PassThru' = $true;
797+
'Wait' = $true;
799798
}
800799
}
801800
([OperatingSystem]::Linux) {
@@ -805,10 +804,10 @@ function Install-UnitySetupPackage {
805804
# Note that $Destination has to be a disk path.
806805
# sudo installer -package $Package.Path -target /
807806
$startProcessArgs = @{
808-
'FilePath' = 'sudo';
807+
'FilePath' = 'sudo';
809808
'ArgumentList' = @("installer", "-package", $Package.Path, "-target", $Destination);
810-
'PassThru' = $true;
811-
'Wait' = $true;
809+
'PassThru' = $true;
810+
'Wait' = $true;
812811
}
813812
}
814813
}
@@ -988,8 +987,7 @@ function Install-UnitySetupInstance {
988987
# Move the install from the sparse bundle disk to the install directory.
989988
if ($currentOS -eq [OperatingSystem]::Mac) {
990989
# 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)) {
993991
Write-Verbose "Creating directory $installPath."
994992
New-Item $installPath -ItemType Directory -ErrorAction Stop | Out-Null
995993
}
@@ -1042,10 +1040,10 @@ function Uninstall-UnitySetupInstance {
10421040
}
10431041

10441042
$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';
10491047
'ArgumentList' = @("/S");
10501048
}
10511049

@@ -1189,10 +1187,10 @@ function Get-UnityProjectInstance {
11891187
)
11901188

11911189
$args = @{
1192-
'Path' = $BasePath;
1193-
'Filter' = 'ProjectSettings';
1190+
'Path' = $BasePath;
1191+
'Filter' = 'ProjectSettings';
11941192
'ErrorAction' = 'Ignore';
1195-
'Directory' = $true;
1193+
'Directory' = $true;
11961194
}
11971195

11981196
if ( $Recurse ) {
@@ -1503,37 +1501,34 @@ function Start-UnityEditor {
15031501
$unityArgs = $sharedArgs | ForEach-Object { $_ }
15041502
if ( $instanceArgs[$i] ) { $unityArgs += $instanceArgs[$i] }
15051503

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-
15191504
$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)"}
15221507

1523-
if (-not $PSCmdlet.ShouldProcess($actionString, "Start-Process")) {
1508+
if (-not $PSCmdlet.ShouldProcess($actionString, "System.Diagnostics.Process.Start()")) {
15241509
continue
15251510
}
15261511

15271512
# Defered till after potential display by ShouldProcess
15281513
if ( $Credential ) { $unityArgs += '-password', $Credential.GetNetworkCredential().Password }
15291514
if ( $Serial ) { $unityArgs += '-serial', [System.Net.NetworkCredential]::new($null, $Serial).Password }
15301515

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+
15361529
if ( $Wait ) {
1530+
$process.WaitForExit()
1531+
15371532
if ( $LogFile -and (Test-Path $LogFile -Type Leaf) ) {
15381533
# Note that Unity sometimes returns a success ExitCode despite the presence of errors, but we want
15391534
# to make sure that we flag such errors.
@@ -1596,7 +1591,7 @@ function Get-IsUnityError {
15961591
function ConvertTo-DateTime {
15971592
param([string] $Text)
15981593

1599-
if( -not $text -or $text.Length -eq 0 ) { [DateTime]::MaxValue }
1594+
if ( -not $text -or $text.Length -eq 0 ) { [DateTime]::MaxValue }
16001595
else { [DateTime]$Text }
16011596
}
16021597

@@ -1608,10 +1603,9 @@ function ConvertTo-DateTime {
16081603
.EXAMPLE
16091604
Get-UnityLicense
16101605
#>
1611-
function Get-UnityLicense
1612-
{
1606+
function Get-UnityLicense {
16131607
[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.")]
16151609
param([SecureString]$Serial)
16161610

16171611
$licenseFiles = Get-ChildItem "C:\ProgramData\Unity\Unity_*.ulf" -ErrorAction 'SilentlyContinue'
@@ -1622,18 +1616,18 @@ function Get-UnityLicense
16221616

16231617
# The first four bytes look like a count so skip that to pull out the serial string
16241618
$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; }
16261620

16271621
$license = $doc.root.License
16281622
[PSCustomObject]@{
16291623
'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
16331627
'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
16371631
}
16381632
}
16391633
}

0 commit comments

Comments
 (0)