unity-azure-pipelines-tasks icon indicating copy to clipboard operation
unity-azure-pipelines-tasks copied to clipboard

Unity build doesn't start due to Logs directory missing

Open devedse opened this issue 5 years ago • 5 comments

Hi all, I'm currently trying to setup a build pipeline for an older Hololens project we've got. It's making use of Unity 2017.4.40f1.

The issue I'm running into is that a Unity build starts but never finishes. I've already been checking the existing github issues but I believe I'm running into a different problem as for example: https://github.com/Dinomite-Studios/unity-azure-pipelines-tasks/issues/137.

The reason is, is that once the Unity build starts, I can see the unity.exe process starting in taskmanager (I'm actually using a tool that shows a bit more details named processhacker). But after a few seconds the unity.exe process stops and leaves no trace behind.

image

From quite a bit of debugging I finally found out what the culprit is. In the directory that's cloned a Logs folder is missing. Apparently the following command fails if there's no Logs directory under the \s\ directory:

"C:\Program Files\Unity\Hub\Editor\2017.4.40f1\Editor\Unity.exe" -batchmode -buildTarget WindowsStoreApps -projectPath C:\agentDS1\_work\15\s -logfile C:\agentDS1\_work\15\s\Logs\UnityBuildLog_2020-07-01-22-12-13.log -nographics -quit -executeMethod AzureDevOps.PerformBuild

If you completely omit the -logfile .... the build also works.

My advise would be to implement logic into the unity-azure-pipelines-tasks to automatically create the \Logs\ directory before starting the build.

Even better would be is that the logging would be automatically piped to Azure DevOps, but I'm not sure if this is possible.

If you guys need, I did create a quite elaborate youtube video showing the problem: https://youtu.be/7OZVh2DDP94

Some usefull timestamps:

  • 0:00 - Kicking the build off from Azure DevOps
  • 3:00 - Unity.exe file being started and quickly exiting again
  • 4:50 - Me executing the unity build command through the command line manually (Doesn't work either)
  • 5:12 - Me executing the unity build command without -logfile, this works fine. You can see the build running for the next ~30 minutes
  • 35:00 - The build completed
  • 35:30 - First I rerun the command again with the -logfile included. This still fails. After I manually created the Logs folder and rerun the unity build command in the command line, everything works. This solved the issue 😄

devedse avatar Jul 01 '20 22:07 devedse

@FejZa , Hi, I saw you are one of the active contributers to this repo. I was wondering if this issue can be fixed in the Azure DevOps task?

devedse avatar Jul 20 '20 23:07 devedse

@FejZa , I was wondering if this issue can be fixed in the future :)

devedse avatar Jun 23 '21 16:06 devedse

Same problem here...

This behavior occurs in all 2017.x versions.

In 2018.x I don't know, in 2019.x I think it doesn't happen and in 2020.x for sure it doesn't.

@FejZa The way to solve it would be to make sure that the folder exists. Reviewing the code I see that the common point for all the tasks is this runner. You would have to make sure the folder exists before running anything:

https://github.com/Dinomite-Studios/unity-devops-utilities/blob/master/lib/unity-tool-runner.ts

It should be really easy, If you don't have time I can do a PR.

EDIT

Temporarily, to work around this I created a task that makes sure the folder exists and simulated the same code as @FejZa to build the log folder.

https://github.com/Dinomite-Studios/unity-azure-pipelines-tasks/blob/main/Tasks/UnityBuild/UnityBuildV2/unity-build.ts#L23

I leave it here in case it helps anyone. It uses PowerShell Core so it can be cross platform.

- task: PowerShell@2
  displayName: Make sure that the Logs folder exists
  inputs:
    targetType: 'inline'
    script: |
      $LogsPath = [IO.Path]::Combine("$(Build.Repository.LocalPath)", "Logs")

      if (!(Test-Path $LogsPath)) {
          New-Item $LogsPath -ItemType Directory
      }
    pwsh: true

bdovaz avatar Jul 20 '21 10:07 bdovaz

Thanks everyone. @bdovaz I can fix this over the weekend. Let me know if you plan to do it earlier. If I don't hear back from you, I'll assume I need to fix it. Thanks!

FejZa avatar Jul 20 '21 10:07 FejZa

Hi @FejZa

Today was setting up my new pipelines for a Unity 2021 upgrade, and I had the same problem as listed above. Even when forcing the creation of the logs it wouldn't work.

Found the culprit though, I always worked with Build Script Execution method (which refers to a custom BuildGame.cs file), and I passed on a parameter called -Version (so I could set versions inside Unity itself).

If I omit this parameter, it works again! I think it is, because the -Version gets passed on by the Dino task, and recently (since 2021), Unity-Editor.exe accepts a parameters -Version.

So the build task wants to start a tail on the log file, but actually the unity editor just exits with the version number stating !!

Hope this helps improving, love what you guys do!

Reinhart

Reinhartdelille avatar Jan 08 '23 14:01 Reinhartdelille