@@ -69,7 +69,7 @@ class UnityProjectInstance
69
69
}
70
70
}
71
71
72
- class UnityVersion
72
+ class UnityVersion : System.IComparable
73
73
{
74
74
[int ] $Major ;
75
75
[int ] $Minor ;
@@ -100,6 +100,14 @@ class UnityVersion
100
100
}
101
101
}
102
102
103
+ [int ] CompareTo([object ]$obj )
104
+ {
105
+ if ($null -eq $obj ) { return 1 }
106
+ if ($obj -isnot [UnityVersion ]) { throw " Object is not a UnityVersion" }
107
+
108
+ return [UnityVersion ]::Compare($this , $obj )
109
+ }
110
+
103
111
static [int ] Compare([UnityVersion ]$a , [UnityVersion ]$b )
104
112
{
105
113
if ($a.Major -lt $b.Major ) { return -1 }
@@ -182,10 +190,15 @@ function Find-UnitySetupInstaller
182
190
' f' { $searchPages += " https://unity3d.com/get-unity/download/archive" }
183
191
' b' { $searchPages += " https://unity3d.com/unity/beta/unity$Version " }
184
192
' p' {
185
- $webResult = Invoke-WebRequest " https://unity3d.com/unity/qa/patch-releases?version=$ ( $Version.Major ) .$ ( $Version.Minor ) "
186
- $searchPages += $webResult.Links | Where-Object { $_.href -match " \/unity\/qa\/patch-releases\?version=$ ( $Version.Major ) \.$ ( $Version.Minor ) &page=(\d+)" } | ForEach-Object {
187
- " https://unity3d.com/unity/qa/patch-releases?version=$ ( $Version.Major ) .$ ( $Version.Minor ) &page=$ ( $Matches [1 ]) "
188
- }
193
+ $patchPage = " https://unity3d.com/unity/qa/patch-releases?version=$ ( $Version.Major ) .$ ( $Version.Minor ) "
194
+ $searchPages += $patchPage
195
+
196
+ $webResult = Invoke-WebRequest $patchPage
197
+ $searchPages += $webResult.Links | Where-Object {
198
+ $_.href -match " \/unity\/qa\/patch-releases\?version=$ ( $Version.Major ) \.$ ( $Version.Minor ) &page=(\d+)" -and $Matches [1 ] -gt 1
199
+ } | ForEach-Object {
200
+ " https://unity3d.com/unity/qa/patch-releases?version=$ ( $Version.Major ) .$ ( $Version.Minor ) &page=$ ( $Matches [1 ]) "
201
+ }
189
202
}
190
203
}
191
204
@@ -196,7 +209,7 @@ function Find-UnitySetupInstaller
196
209
$_ -match " $ ( $installerTemplates [[UnitySetupComponentType ]::Setup ]) $"
197
210
}
198
211
199
- if ($null -eq $prototypeLink ) { break }
212
+ if ($null -ne $prototypeLink ) { break }
200
213
}
201
214
202
215
if ($null -eq $prototypeLink )
@@ -357,6 +370,51 @@ function Install-UnitySetupInstance
357
370
}
358
371
}
359
372
373
+ <#
374
+ . Synopsis
375
+ Uninstall Unity Setup Instances
376
+ . DESCRIPTION
377
+ Uninstall the specified Unity Setup Instances
378
+ . PARAMETER Instance
379
+ What instances of UnitySetup should be uninstalled
380
+ . EXAMPLE
381
+ Get-UnitySetupInstance | Uninstall-UnitySetupInstance
382
+ #>
383
+ function Uninstall-UnitySetupInstance {
384
+ [CmdletBinding (SupportsShouldProcess )]
385
+ param (
386
+ [parameter (Mandatory = $true , ValueFromPipeline = $true )]
387
+ [UnitySetupInstance []] $Instances
388
+ )
389
+
390
+ process {
391
+ foreach ( $setupInstance in $Instances ) {
392
+ $uninstaller = Get-ChildItem " $ ( $setupInstance.Path ) " - Filter ' Uninstall.exe' - Recurse |
393
+ Select-Object - First 1 - ExpandProperty FullName
394
+
395
+ if ($null -eq $uninstaller ) {
396
+ Write-Error " Could not find Uninstaller.exe under $ ( $setupInstance.Path ) "
397
+ continue
398
+ }
399
+
400
+ $startProcessArgs = @ {
401
+ ' FilePath' = $uninstaller ;
402
+ ' PassThru' = $true ;
403
+ ' Wait' = $true ;
404
+ ' ErrorAction' = ' Stop' ;
405
+ ' ArgumentList' = @ (" /S" );
406
+ }
407
+
408
+ if ( -not $PSCmdlet.ShouldProcess (" $uninstaller " , " Start-Process" )) { continue }
409
+
410
+ $process = Start-Process @startProcessArgs
411
+ if ( $process.ExitCode -ne 0 ) {
412
+ Write-Error " Uninstaller quit with non-zero exit code"
413
+ }
414
+ }
415
+ }
416
+ }
417
+
360
418
<#
361
419
. Synopsis
362
420
Get the Unity versions installed
@@ -554,6 +612,10 @@ function Start-UnityEditor
554
612
[parameter (Mandatory = $false )]
555
613
[string ]$ExecuteMethod ,
556
614
[parameter (Mandatory = $false )]
615
+ [string []]$ExportPackage ,
616
+ [parameter (Mandatory = $false )]
617
+ [string ]$CreateProject ,
618
+ [parameter (Mandatory = $false )]
557
619
[string ]$OutputPath ,
558
620
[parameter (Mandatory = $false )]
559
621
[string ]$LogFile ,
@@ -640,12 +702,14 @@ function Start-UnityEditor
640
702
}
641
703
642
704
$sharedArgs = @ ()
705
+ if ( $CreateProject ) { $sharedArgs += " -createProject" , $CreateProject }
643
706
if ( $ExecuteMethod ) { $sharedArgs += " -executeMethod" , $ExecuteMethod }
644
707
if ( $OutputPath ) { $sharedArgs += " -buildOutput" , $OutputPath }
645
708
if ( $LogFile ) { $sharedArgs += " -logFile" , $LogFile }
646
709
if ( $BuildTarget ) { $sharedArgs += " -buildTarget" , $BuildTarget }
647
710
if ( $BatchMode ) { $sharedArgs += " -batchmode" }
648
711
if ( $Quit ) { $sharedArgs += " -quit" }
712
+ if ( $ExportPackage ) { $sharedArgs += " -exportPackage" , " $ExportPackage " }
649
713
650
714
$instanceArgs = @ ()
651
715
foreach ( $p in $projectInstances ) {
@@ -689,7 +753,9 @@ function Start-UnityEditor
689
753
continue
690
754
}
691
755
692
- $unityArgs = $sharedArgs + $instanceArgs [$i ]
756
+ # clone the shared args list
757
+ $unityArgs = $sharedArgs | ForEach-Object { $_ }
758
+ if ( $instanceArgs [$i ] ) { $unityArgs += $instanceArgs [$i ] }
693
759
$setProcessArgs = @ {
694
760
' FilePath' = $editor ;
695
761
' PassThru' = $true ;
@@ -711,9 +777,9 @@ function Start-UnityEditor
711
777
$process.WaitForExit ();
712
778
if ( $process.ExitCode -ne 0 )
713
779
{
714
- if ( $LogFile )
780
+ if ( $LogFile -and ( Test-Path $LogFile - Type Leaf) )
715
781
{
716
- Get-Content $LogFile | Write-Information
782
+ Get-Content $LogFile | ForEach-Object { Write-Information - MessageData $_ - Tags ' Logs ' }
717
783
}
718
784
719
785
Write-Error " Unity quit with non-zero exit code"
0 commit comments