From 17f41236c7ca14b1f660080f887bc360e4c6a97c Mon Sep 17 00:00:00 2001 From: Stephen Hodgson Date: Wed, 9 Jan 2019 08:54:29 -0800 Subject: [PATCH 1/5] added lumin component installers --- UnitySetup/UnitySetup.psm1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/UnitySetup/UnitySetup.psm1 b/UnitySetup/UnitySetup.psm1 index 096b56d..ba5716f 100644 --- a/UnitySetup/UnitySetup.psm1 +++ b/UnitySetup/UnitySetup.psm1 @@ -19,7 +19,8 @@ enum UnitySetupComponent { Facebook = (1 -shl 11) Vuforia = (1 -shl 12) WebGL = (1 -shl 13) - All = (1 -shl 14) - 1 + Lumin = (1 -shl 14) + All = (1 -shl 15) - 1 } [Flags()] @@ -76,6 +77,7 @@ class UnitySetupInstance { [UnitySetupComponent]::UWP_IL2CPP = , [io.path]::Combine("$playbackEnginePath", "MetroSupport\Templates\UWP_IL2CPP_D3D"); [UnitySetupComponent]::Linux = , [io.path]::Combine("$playbackEnginePath", "LinuxStandaloneSupport"); [UnitySetupComponent]::Mac = , [io.path]::Combine("$playbackEnginePath", "MacStandaloneSupport"); + [UnitySetupComponent]::Lumin = , [io.path]::Combine("$playbackEnginePath", "LuminSupport"); } } ([OperatingSystem]::Linux) { @@ -309,6 +311,7 @@ function Find-UnitySetupInstaller { [UnitySetupComponent]::Vuforia = , "$targetSupport/UnitySetup-Vuforia-AR-Support-for-Editor-$Version.$installerExtension"; [UnitySetupComponent]::WebGL = , "$targetSupport/UnitySetup-WebGL-Support-for-Editor-$Version.$installerExtension"; [UnitySetupComponent]::Windows_IL2CPP = , "$targetSupport/UnitySetup-Windows-IL2CPP-Support-for-Editor-$Version.$installerExtension"; + [UnitySetupComponent]::Lumin = , "$targetSupport/UnitySetup-Lumin-Support-for-Editor-$Version.$installerExtension"; } switch ($currentOS) { @@ -819,7 +822,7 @@ function Start-UnityEditor { [parameter(Mandatory = $false)] [string]$LogFile, [parameter(Mandatory = $false)] - [ValidateSet('StandaloneOSX', 'StandaloneWindows', 'iOS', 'Android', 'StandaloneLinux', 'StandaloneWindows64', 'WebGL', 'WSAPlayer', 'StandaloneLinux64', 'StandaloneLinuxUniversal', 'Tizen', 'PSP2', 'PS4', 'XBoxOne', 'N3DS', 'WiiU', 'tvOS', 'Switch')] + [ValidateSet('StandaloneOSX', 'StandaloneWindows', 'iOS', 'Android', 'StandaloneLinux', 'StandaloneWindows64', 'WebGL', 'WSAPlayer', 'StandaloneLinux64', 'StandaloneLinuxUniversal', 'Tizen', 'PSP2', 'PS4', 'XBoxOne', 'N3DS', 'WiiU', 'tvOS', 'Switch', 'Lumin')] [string]$BuildTarget, [parameter(Mandatory = $false)] [switch]$AcceptAPIUpdate, From 0d34c4ed4b006fdbad3479a0fd35092621fd66fd Mon Sep 17 00:00:00 2001 From: Stephen Hodgson Date: Sun, 31 Mar 2019 20:49:51 -0700 Subject: [PATCH 2/5] moved lumin playback engine into common section --- UnitySetup/UnitySetup.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnitySetup/UnitySetup.psm1 b/UnitySetup/UnitySetup.psm1 index 699dc5f..809359a 100644 --- a/UnitySetup/UnitySetup.psm1 +++ b/UnitySetup/UnitySetup.psm1 @@ -82,7 +82,6 @@ class UnitySetupInstance { [UnitySetupComponent]::UWP_IL2CPP = , [io.path]::Combine("$playbackEnginePath", "MetroSupport\Templates\UWP_IL2CPP_D3D"); [UnitySetupComponent]::Linux = , [io.path]::Combine("$playbackEnginePath", "LinuxStandaloneSupport"); [UnitySetupComponent]::Mac = , [io.path]::Combine("$playbackEnginePath", "MacStandaloneSupport"); - [UnitySetupComponent]::Lumin = , [io.path]::Combine("$playbackEnginePath", "LuminSupport"); } } ([OperatingSystem]::Linux) { @@ -103,6 +102,7 @@ class UnitySetupInstance { } # Common playback engines: + $componentTests[[UnitySetupComponent]::Lumin] = , [io.path]::Combine("$playbackEnginePath", "LuminSupport"); $componentTests[[UnitySetupComponent]::Android] = , [io.path]::Combine("$playbackEnginePath", "AndroidPlayer"); $componentTests[[UnitySetupComponent]::iOS] = , [io.path]::Combine("$playbackEnginePath", "iOSSupport"); $componentTests[[UnitySetupComponent]::AppleTV] = , [io.path]::Combine("$playbackEnginePath", "AppleTVSupport"); From 54d86331acd0249fb3b77acd87dc339da482846c Mon Sep 17 00:00:00 2001 From: StephenHodgson Date: Wed, 17 Apr 2019 02:26:33 -0700 Subject: [PATCH 3/5] merged dev branch --- UnitySetup/UnitySetup.psm1 | 229 ++++++++++++++++++------------------- 1 file changed, 113 insertions(+), 116 deletions(-) diff --git a/UnitySetup/UnitySetup.psm1 b/UnitySetup/UnitySetup.psm1 index 809359a..3fc64fb 100644 --- a/UnitySetup/UnitySetup.psm1 +++ b/UnitySetup/UnitySetup.psm1 @@ -19,7 +19,8 @@ enum UnitySetupComponent { Facebook = (1 -shl 11) Vuforia = (1 -shl 12) WebGL = (1 -shl 13) - Lumin = (1 -shl 14) + Mac_IL2CPP = (1 -shl 14) + Lumin = (1 -shl 15) All = (1 -shl 15) - 1 } @@ -74,14 +75,14 @@ class UnitySetupInstance { $this.Components = [UnitySetupComponent]::Windows $playbackEnginePath = [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines"); @{ - [UnitySetupComponent]::Documentation = , [io.path]::Combine("$Path", "Editor\Data\Documentation"); + [UnitySetupComponent]::Documentation = , [io.path]::Combine("$Path", "Editor\Data\Documentation"); [UnitySetupComponent]::StandardAssets = , [io.path]::Combine("$Path", "Editor\Standard Assets"); [UnitySetupComponent]::Windows_IL2CPP = , [io.path]::Combine("$playbackEnginePath", "windowsstandalonesupport\Variations\win32_development_il2cpp"); - [UnitySetupComponent]::UWP = [io.path]::Combine("$playbackEnginePath", "MetroSupport\Templates\UWP_.NET_D3D"), + [UnitySetupComponent]::UWP = [io.path]::Combine("$playbackEnginePath", "MetroSupport\Templates\UWP_.NET_D3D"), [io.path]::Combine("$playbackEnginePath", "MetroSupport\Templates\UWP_D3D"); - [UnitySetupComponent]::UWP_IL2CPP = , [io.path]::Combine("$playbackEnginePath", "MetroSupport\Templates\UWP_IL2CPP_D3D"); - [UnitySetupComponent]::Linux = , [io.path]::Combine("$playbackEnginePath", "LinuxStandaloneSupport"); - [UnitySetupComponent]::Mac = , [io.path]::Combine("$playbackEnginePath", "MacStandaloneSupport"); + [UnitySetupComponent]::UWP_IL2CPP = , [io.path]::Combine("$playbackEnginePath", "MetroSupport\Templates\UWP_IL2CPP_D3D"); + [UnitySetupComponent]::Linux = , [io.path]::Combine("$playbackEnginePath", "LinuxStandaloneSupport"); + [UnitySetupComponent]::Mac = , [io.path]::Combine("$playbackEnginePath", "MacStandaloneSupport"); } } ([OperatingSystem]::Linux) { @@ -93,10 +94,11 @@ class UnitySetupInstance { $this.Components = [UnitySetupComponent]::Mac $playbackEnginePath = [io.path]::Combine("$Path", "PlaybackEngines"); @{ - [UnitySetupComponent]::Documentation = , [io.path]::Combine("$Path", "Documentation"); + [UnitySetupComponent]::Documentation = , [io.path]::Combine("$Path", "Documentation"); [UnitySetupComponent]::StandardAssets = , [io.path]::Combine("$Path", "Standard Assets"); - [UnitySetupComponent]::Windows = , [io.path]::Combine("$playbackEnginePath", "WindowsStandaloneSupport"); - [UnitySetupComponent]::Linux = , [io.path]::Combine("$playbackEnginePath", "LinuxStandaloneSupport"); + [UnitySetupComponent]::Mac_IL2CPP = , [io.path]::Combine("$playbackEnginePath", "MacStandaloneSupport/Variations/macosx64_development_il2cpp"); + [UnitySetupComponent]::Windows = , [io.path]::Combine("$playbackEnginePath", "WindowsStandaloneSupport"); + [UnitySetupComponent]::Linux = , [io.path]::Combine("$playbackEnginePath", "LinuxStandaloneSupport"); } } } @@ -311,18 +313,19 @@ function Find-UnitySetupInstaller { ) $installerTemplates = @{ - [UnitySetupComponent]::UWP = "$targetSupport/UnitySetup-UWP-.NET-Support-for-Editor-$Version.$installerExtension", - "$targetSupport/UnitySetup-Metro-Support-for-Editor-$Version.$installerExtension"; - [UnitySetupComponent]::UWP_IL2CPP = , "$targetSupport/UnitySetup-UWP-IL2CPP-Support-for-Editor-$Version.$installerExtension"; - [UnitySetupComponent]::Android = , "$targetSupport/UnitySetup-Android-Support-for-Editor-$Version.$installerExtension"; - [UnitySetupComponent]::iOS = , "$targetSupport/UnitySetup-iOS-Support-for-Editor-$Version.$installerExtension"; - [UnitySetupComponent]::AppleTV = , "$targetSupport/UnitySetup-AppleTV-Support-for-Editor-$Version.$installerExtension"; - [UnitySetupComponent]::Facebook = , "$targetSupport/UnitySetup-Facebook-Games-Support-for-Editor-$Version.$installerExtension"; - [UnitySetupComponent]::Linux = , "$targetSupport/UnitySetup-Linux-Support-for-Editor-$Version.$installerExtension"; - [UnitySetupComponent]::Mac = "$targetSupport/UnitySetup-Mac-Support-for-Editor-$Version.$installerExtension", + [UnitySetupComponent]::UWP = "$targetSupport/UnitySetup-UWP-.NET-Support-for-Editor-$Version.$installerExtension", + "$targetSupport/UnitySetup-Metro-Support-for-Editor-$Version.$installerExtension"; + [UnitySetupComponent]::UWP_IL2CPP = , "$targetSupport/UnitySetup-UWP-IL2CPP-Support-for-Editor-$Version.$installerExtension"; + [UnitySetupComponent]::Android = , "$targetSupport/UnitySetup-Android-Support-for-Editor-$Version.$installerExtension"; + [UnitySetupComponent]::iOS = , "$targetSupport/UnitySetup-iOS-Support-for-Editor-$Version.$installerExtension"; + [UnitySetupComponent]::AppleTV = , "$targetSupport/UnitySetup-AppleTV-Support-for-Editor-$Version.$installerExtension"; + [UnitySetupComponent]::Facebook = , "$targetSupport/UnitySetup-Facebook-Games-Support-for-Editor-$Version.$installerExtension"; + [UnitySetupComponent]::Linux = , "$targetSupport/UnitySetup-Linux-Support-for-Editor-$Version.$installerExtension"; + [UnitySetupComponent]::Mac = "$targetSupport/UnitySetup-Mac-Support-for-Editor-$Version.$installerExtension", "$targetSupport/UnitySetup-Mac-Mono-Support-for-Editor-$Version.$installerExtension"; - [UnitySetupComponent]::Vuforia = , "$targetSupport/UnitySetup-Vuforia-AR-Support-for-Editor-$Version.$installerExtension"; - [UnitySetupComponent]::WebGL = , "$targetSupport/UnitySetup-WebGL-Support-for-Editor-$Version.$installerExtension"; + [UnitySetupComponent]::Mac_IL2CPP = , "$targetSupport/UnitySetup-Mac-IL2CPP-Support-for-Editor-$Version.$installerExtension"; + [UnitySetupComponent]::Vuforia = , "$targetSupport/UnitySetup-Vuforia-AR-Support-for-Editor-$Version.$installerExtension"; + [UnitySetupComponent]::WebGL = , "$targetSupport/UnitySetup-WebGL-Support-for-Editor-$Version.$installerExtension"; [UnitySetupComponent]::Windows_IL2CPP = , "$targetSupport/UnitySetup-Windows-IL2CPP-Support-for-Editor-$Version.$installerExtension"; [UnitySetupComponent]::Lumin = , "$targetSupport/UnitySetup-Lumin-Support-for-Editor-$Version.$installerExtension"; } @@ -368,8 +371,8 @@ function Find-UnitySetupInstaller { $patchPage = "https://unity3d.com/unity/qa/patch-releases?version=$($Version.Major).$($Version.Minor)" $searchPages += $patchPage - $webResult = Invoke-WebRequest $patchPage -UseBasicParsing - $searchPages += $webResult.Links | Where-Object { + $webResult = Invoke-WebRequest $patchPage -UseBasicParsing + $searchPages += $webResult.Links | Where-Object { $_.href -match "\/unity\/qa\/patch-releases\?version=$($Version.Major)\.$($Version.Minor)&page=(\d+)" -and $Matches[1] -gt 1 } | ForEach-Object { "https://unity3d.com$($_.href)" } } @@ -437,10 +440,10 @@ function Find-UnitySetupInstaller { } $result = New-Object UnitySetupInstaller -Property @{ 'ComponentType' = $_; - 'Version' = $Version; - 'DownloadUrl' = $endpoint; - 'Length' = $installerLength; - 'LastModified' = $lastModified; + 'Version' = $Version; + 'DownloadUrl' = $endpoint; + 'Length' = $installerLength; + 'LastModified' = $lastModified; } break @@ -543,13 +546,13 @@ function Select-UnitySetupInstaller { } filter Format-Bytes { - return "{0:N2} {1}" -f $( - if ($_ -lt 1kb) { $_, 'Bytes' } - elseif ($_ -lt 1mb) { ($_/1kb), 'KB' } - elseif ($_ -lt 1gb) { ($_/1mb), 'MB' } - elseif ($_ -lt 1tb) { ($_/1gb), 'GB' } - elseif ($_ -lt 1pb) { ($_/1tb), 'TB' } - else { ($_/1pb), 'PB' } + return "{0:N2} {1}" -f $( + if ($_ -lt 1kb) { $_, 'Bytes' } + elseif ($_ -lt 1mb) { ($_ / 1kb), 'KB' } + elseif ($_ -lt 1gb) { ($_ / 1mb), 'MB' } + elseif ($_ -lt 1tb) { ($_ / 1gb), 'GB' } + elseif ($_ -lt 1pb) { ($_ / 1tb), 'TB' } + else { ($_ / 1pb), 'PB' } ) } @@ -567,13 +570,13 @@ function Format-BitsPerSecond { } # Convert from bytes to bits $Bits = ($Bytes * 8) / $Seconds - return "{0:N2} {1}" -f $( - if ($Bits -lt 1kb) { $Bits, 'Bps' } - elseif ($Bits -lt 1mb) { ($Bits/1kb), 'Kbps' } - elseif ($Bits -lt 1gb) { ($Bits/1mb), 'Mbps' } - elseif ($Bits -lt 1tb) { ($Bits/1gb), 'Gbps' } - elseif ($Bits -lt 1pb) { ($Bits/1tb), 'Tbps' } - else { ($Bits/1pb), 'Pbps' } + return "{0:N2} {1}" -f $( + if ($Bits -lt 1kb) { $Bits, 'Bps' } + elseif ($Bits -lt 1mb) { ($Bits / 1kb), 'Kbps' } + elseif ($Bits -lt 1gb) { ($Bits / 1mb), 'Mbps' } + elseif ($Bits -lt 1tb) { ($Bits / 1gb), 'Gbps' } + elseif ($Bits -lt 1pb) { ($Bits / 1tb), 'Tbps' } + else { ($Bits / 1pb), 'Pbps' } ) } @@ -641,7 +644,7 @@ function Request-UnitySetupInstaller { $resource = New-Object UnitySetupResource -Property @{ 'ComponentType' = $_.ComponentType - 'Path' = $destination + 'Path' = $destination } $downloads += , $resource return @@ -658,15 +661,15 @@ function Request-UnitySetupInstaller { ++$downloadIndex $global:downloadData[$installerFileName] = New-Object PSObject -Property @{ installerFileName = $installerFileName - startTime = Get-Date - totalBytes = $_.Length - receivedBytes = 0 - isDownloaded = $false - destination = $destination - lastModified = $_.LastModified - componentType = $_.ComponentType - webClient = $webClient - downloadIndex = $downloadIndex + startTime = Get-Date + totalBytes = $_.Length + receivedBytes = 0 + isDownloaded = $false + destination = $destination + lastModified = $_.LastModified + componentType = $_.ComponentType + webClient = $webClient + downloadIndex = $downloadIndex } # Register to events for showing progress of file download. @@ -677,8 +680,7 @@ function Request-UnitySetupInstaller { $global:downloadData[$event.MessageData].isDownloaded = $true } | Out-Null - try - { + try { Write-Verbose "Downloading $($_.DownloadUrl) to $destination" $webClient.DownloadFileAsync($_.DownloadUrl, $destination) } @@ -713,17 +715,17 @@ function Request-UnitySetupInstaller { Unregister-Event -SourceIdentifier "$installerFileName-Completed" -Force Unregister-Event -SourceIdentifier "$installerFileName-Changed" -Force - + $data.webClient.Dispose() $data.webClient = $null # Re-writes the last modified time for ensuring downloads are cached properly. $downloadedFile = Get-Item $data.destination $downloadedFile.LastWriteTime = $data.lastModified - + $resource = New-Object UnitySetupResource -Property @{ 'ComponentType' = $data.componentType - 'Path' = $data.destination + 'Path' = $data.destination } $downloads += , $resource return @@ -732,16 +734,16 @@ function Request-UnitySetupInstaller { $elapsedTime = (Get-Date) - $data.startTime $progress = [int](($data.receivedBytes / [double]$data.totalBytes) * 100) - + $averageSpeed = $data.receivedBytes / $elapsedTime.TotalSeconds $secondsRemaining = ($data.totalBytes - $data.receivedBytes) / $averageSpeed - + if ([double]::IsInfinity($secondsRemaining)) { $averageSpeed = 0 # -1 for Write-Progress prevents seconds remaining from showing. $secondsRemaining = -1 } - + $downloadSpeed = Format-BitsPerSecond -Bytes $data.receivedBytes -Seconds $elapsedTime.TotalSeconds Write-Progress -Activity "Downloading $installerFileName | $downloadSpeed" ` @@ -792,10 +794,10 @@ function Install-UnitySetupPackage { switch ($currentOS) { ([OperatingSystem]::Windows) { $startProcessArgs = @{ - 'FilePath' = $Package.Path; + 'FilePath' = $Package.Path; 'ArgumentList' = @("/S", "/D=$Destination"); - 'PassThru' = $true; - 'Wait' = $true; + 'PassThru' = $true; + 'Wait' = $true; } } ([OperatingSystem]::Linux) { @@ -805,21 +807,21 @@ function Install-UnitySetupPackage { # Note that $Destination has to be a disk path. # sudo installer -package $Package.Path -target / $startProcessArgs = @{ - 'FilePath' = 'sudo'; + 'FilePath' = 'sudo'; 'ArgumentList' = @("installer", "-package", $Package.Path, "-target", $Destination); - 'PassThru' = $true; - 'Wait' = $true; + 'PassThru' = $true; + 'Wait' = $true; } } } - + Write-Verbose "$(Get-Date): Installing $($Package.ComponentType) to $Destination." $process = Start-Process @startProcessArgs if ( $process ) { if ( $process.ExitCode -ne 0) { Write-Error "$(Get-Date): Failed with exit code: $($process.ExitCode)" } - else { + else { Write-Verbose "$(Get-Date): Succeeded." } } @@ -923,7 +925,7 @@ function Install-UnitySetupInstance { $installPath += [io.path]::DirectorySeparatorChar } - # Creating sparse bundle to host installing Unity in other locations + # Creating sparse bundle to host installing Unity in other locations $unitySetupBundlePath = [io.path]::Combine($Cache, "UnitySetup.sparsebundle") if (-not (Test-Path $unitySetupBundlePath)) { Write-Verbose "Creating new sparse bundle disk image for installation." @@ -988,8 +990,7 @@ function Install-UnitySetupInstance { # Move the install from the sparse bundle disk to the install directory. if ($currentOS -eq [OperatingSystem]::Mac) { # rsync does not recursively create the directory path. - if (-not (Test-Path $installPath -PathType Container)) - { + if (-not (Test-Path $installPath -PathType Container)) { Write-Verbose "Creating directory $installPath." New-Item $installPath -ItemType Directory -ErrorAction Stop | Out-Null } @@ -1042,10 +1043,10 @@ function Uninstall-UnitySetupInstance { } $startProcessArgs = @{ - 'FilePath' = $uninstaller; - 'PassThru' = $true; - 'Wait' = $true; - 'ErrorAction' = 'Stop'; + 'FilePath' = $uninstaller; + 'PassThru' = $true; + 'Wait' = $true; + 'ErrorAction' = 'Stop'; 'ArgumentList' = @("/S"); } @@ -1189,10 +1190,10 @@ function Get-UnityProjectInstance { ) $args = @{ - 'Path' = $BasePath; - 'Filter' = 'ProjectSettings'; + 'Path' = $BasePath; + 'Filter' = 'ProjectSettings'; 'ErrorAction' = 'Ignore'; - 'Directory' = $true; + 'Directory' = $true; } if ( $Recurse ) { @@ -1312,7 +1313,7 @@ function Start-UnityEditor { [parameter(Mandatory = $false)] [string]$LogFile, [parameter(Mandatory = $false)] - [ValidateSet('StandaloneOSX', 'StandaloneWindows', 'iOS', 'Android', 'StandaloneLinux', 'StandaloneWindows64', 'WebGL', 'WSAPlayer', 'StandaloneLinux64', 'StandaloneLinuxUniversal', 'Tizen', 'PSP2', 'PS4', 'XBoxOne', 'N3DS', 'WiiU', 'tvOS', 'Switch', 'Lumin')] + [ValidateSet('StandaloneOSX', 'StandaloneWindows', 'iOS', 'Android', 'StandaloneLinux', 'StandaloneWindows64', 'WebGL', 'WSAPlayer', 'StandaloneLinux64', 'StandaloneLinuxUniversal', 'Tizen', 'PSP2', 'PS4', 'XBoxOne', 'N3DS', 'WiiU', 'tvOS', 'Switch')] [string]$BuildTarget, [parameter(Mandatory = $false)] [switch]$AcceptAPIUpdate, @@ -1417,7 +1418,7 @@ function Start-UnityEditor { if ( -not $PSBoundParameters.ContainsKey('BatchMode') ) { $BatchMode = $true } if ( -not $PSBoundParameters.ContainsKey('Quit') ) { $Quit = $true } } - if ( $AcceptAPIUpdate ) { + if ( $AcceptAPIUpdate ) { $sharedArgs += '-accept-apiupdate' if ( -not $PSBoundParameters.ContainsKey('BatchMode')) { $BatchMode = $true } } @@ -1480,7 +1481,7 @@ function Start-UnityEditor { ([OperatingSystem]::Windows) { $editor = Get-ChildItem "$($setupInstance.Path)" -Filter 'Unity.exe' -Recurse | Select-Object -First 1 -ExpandProperty FullName - + if ([string]::IsNullOrEmpty($editor)) { Write-Error "Could not find Unity.exe under setup instance path: $($setupInstance.Path)" continue @@ -1491,7 +1492,7 @@ function Start-UnityEditor { } ([OperatingSystem]::Mac) { $editor = [io.path]::Combine("$($setupInstance.Path)", "Unity.app/Contents/MacOS/Unity") - + if ([string]::IsNullOrEmpty($editor)) { Write-Error "Could not find Unity app under setup instance path: $($setupInstance.Path)" continue @@ -1503,24 +1504,11 @@ function Start-UnityEditor { $unityArgs = $sharedArgs | ForEach-Object { $_ } if ( $instanceArgs[$i] ) { $unityArgs += $instanceArgs[$i] } - $setProcessArgs = @{ - 'FilePath' = $editor; - 'PassThru' = $true; - 'ErrorAction' = 'Stop'; - 'RedirectStandardOutput' = New-TemporaryFile; - 'RedirectStandardError' = New-TemporaryFile; - } - - if ($Wait) { $setProcessArgs['Wait'] = $true } - - Write-Verbose "Redirecting standard output to $($setProcessArgs['RedirectStandardOutput'])" - Write-Verbose "Redirecting standard error to $($setProcessArgs['RedirectStandardError'])" - $actionString = "$editor $unityArgs" - if( $Credential ) { $actionString += " -password (hidden)"} - if( $Serial ) { $actionString += " -serial (hidden)"} + if ( $Credential ) { $actionString += " -password (hidden)"} + if ( $Serial ) { $actionString += " -serial (hidden)"} - if (-not $PSCmdlet.ShouldProcess($actionString, "Start-Process")) { + if (-not $PSCmdlet.ShouldProcess($actionString, "System.Diagnostics.Process.Start()")) { continue } @@ -1528,17 +1516,27 @@ function Start-UnityEditor { if ( $Credential ) { $unityArgs += '-password', $Credential.GetNetworkCredential().Password } if ( $Serial ) { $unityArgs += '-serial', [System.Net.NetworkCredential]::new($null, $Serial).Password } - if ($unityArgs -and $unityArgs.Length -gt 0) { - $setProcessArgs['ArgumentList'] = $unityArgs - } + # We've experienced issues with Start-Process -Wait and redirecting + # output so we're using the Process class directly now. + $process = New-Object System.Diagnostics.Process + $process.StartInfo.Filename = $editor + $process.StartInfo.Arguments = $unityArgs + $process.StartInfo.RedirectStandardOutput = $true + $process.StartInfo.RedirectStandardError = $true + $process.StartInfo.UseShellExecute = $false + $process.StartInfo.CreateNoWindow = $true + $process.StartInfo.WorkingDirectory = $PWD + $process.StartInfo.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Hidden + $process.Start() | Out-Null - $process = Start-Process @setProcessArgs if ( $Wait ) { + $process.WaitForExit() + if ( $LogFile -and (Test-Path $LogFile -Type Leaf) ) { # Note that Unity sometimes returns a success ExitCode despite the presence of errors, but we want # to make sure that we flag such errors. Write-UnityErrors $LogFile - + Write-Verbose "Writing $LogFile to Information stream Tagged as 'Logs'" Get-Content $LogFile | ForEach-Object { Write-Information -MessageData $_ -Tags 'Logs' } } @@ -1596,7 +1594,7 @@ function Get-IsUnityError { function ConvertTo-DateTime { param([string] $Text) - if( -not $text -or $text.Length -eq 0 ) { [DateTime]::MaxValue } + if ( -not $text -or $text.Length -eq 0 ) { [DateTime]::MaxValue } else { [DateTime]$Text } } @@ -1608,10 +1606,9 @@ function ConvertTo-DateTime { .EXAMPLE Get-UnityLicense #> -function Get-UnityLicense -{ +function Get-UnityLicense { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "", Justification="Used to convert discovered plaintext serials into secure strings.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "", Justification = "Used to convert discovered plaintext serials into secure strings.")] param([SecureString]$Serial) $licenseFiles = Get-ChildItem "C:\ProgramData\Unity\Unity_*.ulf" -ErrorAction 'SilentlyContinue' @@ -1622,18 +1619,18 @@ function Get-UnityLicense # The first four bytes look like a count so skip that to pull out the serial string $licenseSerial = [String]::new($devBytes[4..($devBytes.Length - 1)]) - if( $Serial -and [System.Net.NetworkCredential]::new($null, $Serial).Password -ne $licenseSerial ) { continue; } - + if ( $Serial -and [System.Net.NetworkCredential]::new($null, $Serial).Password -ne $licenseSerial ) { continue; } + $license = $doc.root.License [PSCustomObject]@{ 'LicenseVersion' = $license.LicenseVersion.Value - 'Serial' = ConvertTo-SecureString $licenseSerial -AsPlainText -Force - 'UnityVersion' = [UnityVersion]$license.ClientProvidedVersion.Value - 'DisplaySerial' = $license.SerialMasked.Value + 'Serial' = ConvertTo-SecureString $licenseSerial -AsPlainText -Force + 'UnityVersion' = [UnityVersion]$license.ClientProvidedVersion.Value + 'DisplaySerial' = $license.SerialMasked.Value 'ActivationDate' = ConvertTo-DateTime $license.InitialActivationDate.Value - 'StartDate' = ConvertTo-DateTime $license.StartDate.Value - 'StopDate' = ConvertTo-DateTime $license.StopDate.Value - 'UpdateDate' = ConvertTo-DateTime $license.UpdateDate.Value + 'StartDate' = ConvertTo-DateTime $license.StartDate.Value + 'StopDate' = ConvertTo-DateTime $license.StopDate.Value + 'UpdateDate' = ConvertTo-DateTime $license.UpdateDate.Value } } } @@ -1647,11 +1644,11 @@ function Get-UnityLicense $alias = Get-Alias -Name $_.Name -ErrorAction 'SilentlyContinue' if ( -not $alias ) { - Write-Verbose "Creating new alias $($_.Name) for $($_.Value)" - New-Alias @_ + Write-Verbose "Creating new alias $($_.Name) for $($_.Value)" + New-Alias @_ } elseif ( $alias.ModuleName -eq 'UnitySetup' ) { - Write-Verbose "Setting alias $($_.Name) to $($_.Value)" + Write-Verbose "Setting alias $($_.Name) to $($_.Value)" Set-Alias @_ } else { From 9d350e3d4ae94a6bf88d1bf2385567569d506cd9 Mon Sep 17 00:00:00 2001 From: StephenHodgson Date: Thu, 18 Apr 2019 20:25:41 -0700 Subject: [PATCH 4/5] added lumin back to the parameter list for build platform --- UnitySetup/UnitySetup.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnitySetup/UnitySetup.psm1 b/UnitySetup/UnitySetup.psm1 index 3fc64fb..1dd5098 100644 --- a/UnitySetup/UnitySetup.psm1 +++ b/UnitySetup/UnitySetup.psm1 @@ -1313,7 +1313,7 @@ function Start-UnityEditor { [parameter(Mandatory = $false)] [string]$LogFile, [parameter(Mandatory = $false)] - [ValidateSet('StandaloneOSX', 'StandaloneWindows', 'iOS', 'Android', 'StandaloneLinux', 'StandaloneWindows64', 'WebGL', 'WSAPlayer', 'StandaloneLinux64', 'StandaloneLinuxUniversal', 'Tizen', 'PSP2', 'PS4', 'XBoxOne', 'N3DS', 'WiiU', 'tvOS', 'Switch')] + [ValidateSet('StandaloneOSX', 'StandaloneWindows', 'iOS', 'Android', 'StandaloneLinux', 'StandaloneWindows64', 'WebGL', 'WSAPlayer', 'StandaloneLinux64', 'StandaloneLinuxUniversal', 'Tizen', 'PSP2', 'PS4', 'XBoxOne', 'N3DS', 'WiiU', 'tvOS', 'Switch', 'Lumin')] [string]$BuildTarget, [parameter(Mandatory = $false)] [switch]$AcceptAPIUpdate, From 780fd29f4f4b1caa71b1116c156b73d723f0e741 Mon Sep 17 00:00:00 2001 From: StephenHodgson Date: Thu, 18 Apr 2019 20:33:15 -0700 Subject: [PATCH 5/5] fixed spacing --- UnitySetup/UnitySetup.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnitySetup/UnitySetup.psm1 b/UnitySetup/UnitySetup.psm1 index 1dd5098..a0ab1b6 100644 --- a/UnitySetup/UnitySetup.psm1 +++ b/UnitySetup/UnitySetup.psm1 @@ -327,7 +327,7 @@ function Find-UnitySetupInstaller { [UnitySetupComponent]::Vuforia = , "$targetSupport/UnitySetup-Vuforia-AR-Support-for-Editor-$Version.$installerExtension"; [UnitySetupComponent]::WebGL = , "$targetSupport/UnitySetup-WebGL-Support-for-Editor-$Version.$installerExtension"; [UnitySetupComponent]::Windows_IL2CPP = , "$targetSupport/UnitySetup-Windows-IL2CPP-Support-for-Editor-$Version.$installerExtension"; - [UnitySetupComponent]::Lumin = , "$targetSupport/UnitySetup-Lumin-Support-for-Editor-$Version.$installerExtension"; + [UnitySetupComponent]::Lumin = , "$targetSupport/UnitySetup-Lumin-Support-for-Editor-$Version.$installerExtension"; } switch ($currentOS) {