@@ -162,7 +162,7 @@ class UnityVersion : System.IComparable {
162
162
UnityVersion([string ] $version ) {
163
163
$parts = $version.Split (' -' )
164
164
165
- $parts [0 ] -match " (\d+)\.(\d+)\.(\d+)([fpb ])(\d+)" | Out-Null
165
+ $parts [0 ] -match " (\d+)\.(\d+)\.(\d+)([fpba ])(\d+)" | Out-Null
166
166
if ( $Matches.Count -ne 6 ) { throw " Invalid unity version: $version " }
167
167
$this.Major = [int ]($Matches [1 ]);
168
168
$this.Minor = [int ]($Matches [2 ]);
@@ -290,20 +290,20 @@ function Find-UnitySetupInstaller {
290
290
$currentOS = Get-OperatingSystem
291
291
switch ($currentOS ) {
292
292
([OperatingSystem ]::Windows) {
293
- $unitySetupRegEx = " ^(.+)\/([a-z0-9]+)\/Windows64EditorInstaller\/UnitySetup64-(\d+)\.(\d+)\.(\d+)([fpb])(\d+).exe$"
294
293
$targetSupport = " TargetSupportInstaller"
295
294
$installerExtension = " exe"
296
295
}
297
296
([OperatingSystem ]::Linux) {
298
297
throw " Find-UnitySetupInstaller has not been implemented on the Linux platform. Contributions welcomed!" ;
299
298
}
300
299
([OperatingSystem ]::Mac) {
301
- $unitySetupRegEx = " ^(.+)\/([a-z0-9]+)\/MacEditorInstaller\/Unity-(\d+)\.(\d+)\.(\d+)([fpb])(\d+).pkg$"
302
300
$targetSupport = " MacEditorTargetInstaller"
303
301
$installerExtension = " pkg"
304
302
}
305
303
}
306
304
305
+ $unitySetupRegEx = " ^(.+)\/([a-z0-9]+)\/(.+)\/(.+)-(\d+)\.(\d+)\.(\d+)([fpba])(\d+).$installerExtension $"
306
+
307
307
$knownBaseUrls = @ (
308
308
" https://download.unity3d.com/download_unity" ,
309
309
" https://netstorage.unity3d.com/unity" ,
@@ -312,7 +312,8 @@ function Find-UnitySetupInstaller {
312
312
313
313
$installerTemplates = @ {
314
314
[UnitySetupComponent ]::UWP = " $targetSupport /UnitySetup-UWP-.NET-Support-for-Editor-$Version .$installerExtension " ,
315
- " $targetSupport /UnitySetup-Metro-Support-for-Editor-$Version .$installerExtension " ;
315
+ " $targetSupport /UnitySetup-Metro-Support-for-Editor-$Version .$installerExtension " ,
316
+ " $targetSupport /UnitySetup-Universal-Windows-Platform-Support-for-Editor-$Version .$installerExtension " ;
316
317
[UnitySetupComponent ]::UWP_IL2CPP = , " $targetSupport /UnitySetup-UWP-IL2CPP-Support-for-Editor-$Version .$installerExtension " ;
317
318
[UnitySetupComponent ]::Android = , " $targetSupport /UnitySetup-Android-Support-for-Editor-$Version .$installerExtension " ;
318
319
[UnitySetupComponent ]::iOS = , " $targetSupport /UnitySetup-iOS-Support-for-Editor-$Version .$installerExtension " ;
@@ -362,8 +363,23 @@ function Find-UnitySetupInstaller {
362
363
# Every release type has a different pattern for finding installers
363
364
$searchPages = @ ()
364
365
switch ($Version.Release ) {
365
- ' f' { $searchPages += " https://unity3d.com/get-unity/download/archive" }
366
- ' b' { $searchPages += " https://unity3d.com/unity/beta/unity$Version " }
366
+ ' a' { $searchPages += " https://unity3d.com/alpha/$ ( $Version.Major ) .$ ( $Version.Minor ) " }
367
+ ' b' {
368
+ $searchPages += " https://unity3d.com/unity/beta/unity$Version " ,
369
+ " https://unity3d.com/unity/beta/$ ( $Version.Major ) .$ ( $Version.Minor ) " ,
370
+ " https://unity3d.com/unity/beta/$Version "
371
+ }
372
+ ' f' {
373
+ $searchPages += " https://unity3d.com/get-unity/download/archive" ,
374
+ " https://unity3d.com/unity/whats-new/$ ( $Version.Major ) .$ ( $Version.Minor ) .$ ( $Version.Revision ) "
375
+
376
+ # Just in case it's a release candidate search the beta as well.
377
+ if ($Version.Revision -eq ' 0' ) {
378
+ $searchPages += " https://unity3d.com/unity/beta/unity$Version " ,
379
+ " https://unity3d.com/unity/beta/$ ( $Version.Major ) .$ ( $Version.Minor ) " ,
380
+ " https://unity3d.com/unity/beta/$Version "
381
+ }
382
+ }
367
383
' p' {
368
384
$patchPage = " https://unity3d.com/unity/qa/patch-releases?version=$ ( $Version.Major ) .$ ( $Version.Minor ) "
369
385
$searchPages += $patchPage
@@ -376,35 +392,32 @@ function Find-UnitySetupInstaller {
376
392
}
377
393
378
394
foreach ($page in $searchPages ) {
379
- $webResult = Invoke-WebRequest $page - UseBasicParsing
380
- $prototypeLink = $webResult.Links | Select-Object - ExpandProperty href - ErrorAction SilentlyContinue | Where-Object {
381
- $_ -match " $ ( $installerTemplates [$setupComponent ]) $"
382
- }
383
-
384
- if ($null -ne $prototypeLink ) { break }
385
- }
386
-
387
- if ($null -eq $prototypeLink ) {
388
- # Attempt to find Unity version and setup links based off builtin_shaders download.
389
- Write-Verbose " Attempting version search with builtin_shaders fallback"
390
- foreach ($page in $searchPages ) {
395
+ try {
391
396
$webResult = Invoke-WebRequest $page - UseBasicParsing
392
397
$prototypeLink = $webResult.Links | Select-Object - ExpandProperty href - ErrorAction SilentlyContinue | Where-Object {
393
- $_ -match " builtin_shaders-$ ( $Version ) .zip$"
394
- }
398
+ $link = $_
395
399
396
- if ($null -ne $prototypeLink ) { break }
397
- }
400
+ foreach ( $installer in $installerTemplates.Keys ) {
401
+ foreach ( $template in $installerTemplates [$installer ] ) {
402
+ if ( $link -like " *$template *" ) { return $true }
403
+ }
404
+ }
405
+
406
+ return $false
407
+
408
+ } | Select-Object - First 1
398
409
399
- if ($null -eq $prototypeLink ) {
400
- throw " Could not find archives for Unity version $Version "
410
+ if ($null -ne $prototypeLink ) { break }
401
411
}
402
- else {
403
- # Regex needs to be reconfigured to parse builtin_shaders's url link
404
- $unitySetupRegEx = " ^(.+)\/([a-z0-9]+)\/builtin_shaders-(\d+)\.(\d+)\.(\d+)([fpb])(\d+).zip$"
412
+ catch {
413
+ Write-Verbose " $page failed: $ ( $_.Exception.Message ) "
405
414
}
406
415
}
407
416
417
+ if ($null -eq $prototypeLink ) {
418
+ throw " Could not find archives for Unity version $Version "
419
+ }
420
+
408
421
$linkComponents = $prototypeLink -split $unitySetupRegEx -ne " "
409
422
410
423
if ($knownBaseUrls -notcontains $linkComponents [0 ]) {
@@ -446,7 +459,7 @@ function Find-UnitySetupInstaller {
446
459
break
447
460
}
448
461
catch {
449
- Write-Verbose " $endpoint failed: $_ "
462
+ Write-Verbose " $endpoint failed: $ ( $_ .Exception.Message ) "
450
463
}
451
464
}
452
465
0 commit comments