@@ -1387,7 +1387,16 @@ function Test-UnityProjectInstanceMetaFileIntegrity {
13871387 [System.IO.DirectoryInfo []]$dirs = Get-ChildItem - Path " $assetDir /*" - Recurse - Directory - Exclude ' .*'
13881388
13891389 Write-Verbose " Testing asset directories for missing meta files..."
1390+ [float ]$progressCounter = 0
13901391 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+
13911400 $testPath = " $ ( $dir.FullName ) .meta" ;
13921401 if (Test-Path - PathType Leaf - Path $testPath ) { continue }
13931402
@@ -1412,7 +1421,16 @@ function Test-UnityProjectInstanceMetaFileIntegrity {
14121421 }
14131422
14141423 Write-Verbose " Testing asset files for missing meta files..."
1424+ $progressCounter = 0
14151425 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+
14161434 $testPath = " $ ( $file.FullName ) .meta" ;
14171435 if (Test-Path - PathType Leaf - Path $testPath ) { continue }
14181436
@@ -1444,7 +1462,16 @@ function Test-UnityProjectInstanceMetaFileIntegrity {
14441462 }
14451463
14461464 Write-Verbose " Testing meta files for missing assets..."
1465+ $progressCounter = 0
14471466 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+
14481475 $testPath = $metaFile.FullName.SubString (0 , $metaFile.FullName.Length - $metaFile.Extension.Length );
14491476 if (Test-Path - Path $testPath ) { continue }
14501477
@@ -1464,22 +1491,42 @@ function Test-UnityProjectInstanceMetaFileIntegrity {
14641491
14651492 Write-Verbose " Testing meta files for guid collisions..."
14661493 $metaGuids = @ { }
1494+ $progressCounter = 0
14671495 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 )
14721501 }
1502+ Write-Progress @progress
14731503
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 ;
14781526 }
14791527 }
1480- else {
1481- $testResult = $false ;
1482- break ;
1528+ catch {
1529+ Write-Error " Exception testing guid of $metaFile - $_ "
14831530 }
14841531 }
14851532
0 commit comments