@@ -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+)([fpba])(\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+)([fpba])(\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,16 +363,22 @@ function Find-UnitySetupInstaller {
362
363
# Every release type has a different pattern for finding installers
363
364
$searchPages = @ ()
364
365
switch ($Version.Release ) {
365
- ' a' { $searchPages += " https://unity3d.com/unity/beta/unity$Version " }
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
+ }
367
371
' f' {
368
- $searchPages += " https://unity3d.com/get-unity/download/archive"
369
-
370
- # Just in case it's a release candidate search the beta as well.
371
- if ($Version.Revision -eq ' 0' ) {
372
- $searchPages += " https://unity3d.com/unity/beta/unity$Version "
373
- }
372
+ $searchPages += " https://unity3d.com/get-unity/download/archive" ,
373
+ " https://unity3d.com/unity/whats-new/$ ( $Version.Major ) .$ ( $Version.Minor ) .$ ( $Version.Revision ) "
374
+
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
+ $searchPages += " https://unity3d.com/unity/beta/$ ( $Version.Major ) .$ ( $Version.Minor ) "
374
380
}
381
+ }
375
382
' p' {
376
383
$patchPage = " https://unity3d.com/unity/qa/patch-releases?version=$ ( $Version.Major ) .$ ( $Version.Minor ) "
377
384
$searchPages += $patchPage
@@ -384,35 +391,32 @@ function Find-UnitySetupInstaller {
384
391
}
385
392
386
393
foreach ($page in $searchPages ) {
387
- $webResult = Invoke-WebRequest $page - UseBasicParsing
388
- $prototypeLink = $webResult.Links | Select-Object - ExpandProperty href - ErrorAction SilentlyContinue | Where-Object {
389
- $_ -match " $ ( $installerTemplates [$setupComponent ]) $"
390
- }
391
-
392
- if ($null -ne $prototypeLink ) { break }
393
- }
394
-
395
- if ($null -eq $prototypeLink ) {
396
- # Attempt to find Unity version and setup links based off builtin_shaders download.
397
- Write-Verbose " Attempting version search with builtin_shaders fallback"
398
- foreach ($page in $searchPages ) {
394
+ try {
399
395
$webResult = Invoke-WebRequest $page - UseBasicParsing
400
396
$prototypeLink = $webResult.Links | Select-Object - ExpandProperty href - ErrorAction SilentlyContinue | Where-Object {
401
- $_ -match " builtin_shaders-$ ( $Version ) .zip$"
402
- }
397
+ $link = $_
403
398
404
- if ($null -ne $prototypeLink ) { break }
405
- }
399
+ foreach ( $installer in $installerTemplates.Keys ) {
400
+ foreach ( $template in $installerTemplates [$installer ] ) {
401
+ if ( $link -like " *$template *" ) { return $true }
402
+ }
403
+ }
404
+
405
+ return $false
406
+
407
+ } | Select-Object - First 1
406
408
407
- if ($null -eq $prototypeLink ) {
408
- throw " Could not find archives for Unity version $Version "
409
+ if ($null -ne $prototypeLink ) { break }
409
410
}
410
- else {
411
- # Regex needs to be reconfigured to parse builtin_shaders's url link
412
- $unitySetupRegEx = " ^(.+)\/([a-z0-9]+)\/builtin_shaders-(\d+)\.(\d+)\.(\d+)([fpba])(\d+).zip$"
411
+ catch {
412
+ Write-Verbose " $page failed: $ ( $_.Exception.Message ) "
413
413
}
414
414
}
415
415
416
+ if ($null -eq $prototypeLink ) {
417
+ throw " Could not find archives for Unity version $Version "
418
+ }
419
+
416
420
$linkComponents = $prototypeLink -split $unitySetupRegEx -ne " "
417
421
418
422
if ($knownBaseUrls -notcontains $linkComponents [0 ]) {
@@ -454,7 +458,7 @@ function Find-UnitySetupInstaller {
454
458
break
455
459
}
456
460
catch {
457
- Write-Verbose " $endpoint failed: $_ "
461
+ Write-Verbose " $endpoint failed: $ ( $_ .Exception.Message ) "
458
462
}
459
463
}
460
464
0 commit comments