@@ -964,6 +964,7 @@ function Start-UnityEditor {
964
964
if ( $Wait ) {
965
965
if ( $process.ExitCode -ne 0 ) {
966
966
if ( $LogFile -and (Test-Path $LogFile - Type Leaf) ) {
967
+ Write-UnityErrors $LogFile
967
968
Write-Verbose " Writing $LogFile to Information stream Tagged as 'Logs'"
968
969
Get-Content $LogFile | ForEach-Object { Write-Information - MessageData $_ - Tags ' Logs' }
969
970
}
@@ -977,6 +978,32 @@ function Start-UnityEditor {
977
978
}
978
979
}
979
980
981
+ # Open the specified Unity log file and write any errors found in the file to the error stream.
982
+ function Write-UnityErrors {
983
+ param ([string ] $LogFileName )
984
+ $errors = Get-Content $LogFileName | Where-Object { Get-IsUnityError $_ }
985
+ if ( $errors.Count -gt 0 ) {
986
+ $errorMessage = $errors -join " `r`n "
987
+ $errorMessage = " Errors were found in $LogFileName `:`r`n $errorMessage "
988
+ Write-Error $errorMessage
989
+ }
990
+ }
991
+
992
+ function Get-IsUnityError {
993
+ param ([string ] $LogLine )
994
+
995
+ # Detect compilation error, for example:
996
+ # Assets/Errors.cs(7,9): error CS0103: The name `NonexistentFunction' does not exist in the current context
997
+ if ( $LogLine -match ' \.cs\(\d+,\d+\): error ' ) {
998
+ return $true
999
+ }
1000
+
1001
+ # In the future, additional kinds of errors that can be found in Unity logs could be added here:
1002
+ # ...
1003
+
1004
+ return $false
1005
+ }
1006
+
980
1007
function ConvertTo-DateTime {
981
1008
param ([string ] $Text )
982
1009
0 commit comments