@@ -1387,7 +1387,16 @@ function Test-UnityProjectInstanceMetaFileIntegrity {
1387
1387
[System.IO.DirectoryInfo []]$dirs = Get-ChildItem - Path " $assetDir /*" - Recurse - Directory - Exclude ' .*'
1388
1388
1389
1389
Write-Verbose " Testing asset directories for missing meta files..."
1390
+ [float ]$progressCounter = 0
1390
1391
foreach ($dir in $dirs ) {
1392
+
1393
+ $progress = @ {
1394
+ ' Activity' = " Testing directories for missing meta files"
1395
+ ' Status' = $dir
1396
+ ' PercentComplete' = (((++ $progressCounter ) / $dirs.Length ) * 100 )
1397
+ }
1398
+ Write-Progress @progress
1399
+
1391
1400
$testPath = " $ ( $dir.FullName ) .meta" ;
1392
1401
if (Test-Path - PathType Leaf - Path $testPath ) { continue }
1393
1402
@@ -1412,7 +1421,16 @@ function Test-UnityProjectInstanceMetaFileIntegrity {
1412
1421
}
1413
1422
1414
1423
Write-Verbose " Testing asset files for missing meta files..."
1424
+ $progressCounter = 0
1415
1425
foreach ( $file in $files ) {
1426
+
1427
+ $progress = @ {
1428
+ ' Activity' = " Testing files for missing meta files"
1429
+ ' Status' = $file
1430
+ ' PercentComplete' = (((++ $progressCounter ) / $files.Length ) * 100 )
1431
+ }
1432
+ Write-Progress @progress
1433
+
1416
1434
$testPath = " $ ( $file.FullName ) .meta" ;
1417
1435
if (Test-Path - PathType Leaf - Path $testPath ) { continue }
1418
1436
@@ -1444,7 +1462,16 @@ function Test-UnityProjectInstanceMetaFileIntegrity {
1444
1462
}
1445
1463
1446
1464
Write-Verbose " Testing meta files for missing assets..."
1465
+ $progressCounter = 0
1447
1466
foreach ($metaFile in $metaFiles ) {
1467
+
1468
+ $progress = @ {
1469
+ ' Activity' = " Testing meta files for missing assets"
1470
+ ' Status' = $metaFile
1471
+ ' PercentComplete' = (((++ $progressCounter ) / $metaFiles.Length ) * 100 )
1472
+ }
1473
+ Write-Progress @progress
1474
+
1448
1475
$testPath = $metaFile.FullName.SubString (0 , $metaFile.FullName.Length - $metaFile.Extension.Length );
1449
1476
if (Test-Path - Path $testPath ) { continue }
1450
1477
@@ -1464,22 +1491,42 @@ function Test-UnityProjectInstanceMetaFileIntegrity {
1464
1491
1465
1492
Write-Verbose " Testing meta files for guid collisions..."
1466
1493
$metaGuids = @ { }
1494
+ $progressCounter = 0
1467
1495
foreach ($metaFile in $metaFiles ) {
1468
- $metaContent = Get-Content $metaFile.FullName - Raw | ConvertFrom-Yaml
1469
- if ($null -eq $metaGuids [$metaContent.guid ]) {
1470
- $metaGuids [$metaContent.guid ] = $metaFile ;
1471
- continue
1496
+
1497
+ $progress = @ {
1498
+ ' Activity' = " Testing meta files for guid collisions"
1499
+ ' Status' = $metaFile
1500
+ ' PercentComplete' = (((++ $progressCounter ) / $metaFiles.Length ) * 100 )
1472
1501
}
1502
+ Write-Progress @progress
1473
1503
1474
- if ($PassThru ) {
1475
- [PSCustomObject ]@ {
1476
- ' Item' = $metaFile
1477
- ' Issue' = " Meta file guid collision with $ ( $metaGuids [$metaContent.guid ]) "
1504
+ try {
1505
+ $guidResult = Get-Content $metaFile.FullName | Select-String - Pattern ' ^guid:\s*([a-z,A-Z,\d]+)\s*$'
1506
+ if ($guidResult.Matches.Groups.Length -lt 2 ) {
1507
+ Write-Warning " Could not find guid in meta file - $metaFile "
1508
+ continue ;
1509
+ }
1510
+
1511
+ $guid = $guidResult.Matches.Groups [1 ].Value
1512
+ if ($null -eq $metaGuids [$guid ]) {
1513
+ $metaGuids [$guid ] = $metaFile ;
1514
+ continue
1515
+ }
1516
+
1517
+ if ($PassThru ) {
1518
+ [PSCustomObject ]@ {
1519
+ ' Item' = $metaFile
1520
+ ' Issue' = " Meta file guid collision with $ ( $metaGuids [$guid ]) "
1521
+ }
1522
+ }
1523
+ else {
1524
+ $testResult = $false ;
1525
+ break ;
1478
1526
}
1479
1527
}
1480
- else {
1481
- $testResult = $false ;
1482
- break ;
1528
+ catch {
1529
+ Write-Error " Exception testing guid of $metaFile - $_ "
1483
1530
}
1484
1531
}
1485
1532
0 commit comments