I have set up Jenkins to build our Unity projects. It takes the project from git and builds Windows and Web simultaneously. I use seperate project folders for each build type so that Unity doesn’t trip over itself when compiling. 99.9% of the time this works just fine, and I see log files that look like the following:
BATCHMODE ARGUMENTS:
C:\Program Files (x86)\Unity-4.5\Editor\Unity.exe
-projectPath
C:\Jenkins\jobs\unity-web\workspace
-quit
-batchmode
-nographics
-logFile
C:\Jenkins\jobs\unity-web\workspace\bin\build.log
-buildWebPlayer
C:\Jenkins\jobs\unity-web\workspace\bin\my-game
Successfully changed project path to: C:\Jenkins\jobs\unity-web\workspace
C:/Jenkins/jobs/unity-web/workspace
0.1% of the time it doesn’t work:
BATCHMODE ARGUMENTS:
C:\Program Files (x86)\Unity-4.5\Editor\Unity.exe
-projectPath
C:\Jenkins\jobs\unity-web\workspace
-quit
-batchmode
-nographics
-logFile
C:\Jenkins\jobs\unity-web\workspace\bin\build.log
-buildWebPlayer
C:\Jenkins\jobs\unity-web\workspace\bin\my-game
Successfully changed project path to: C:\Jenkins\jobs\unity-web\workspace
C:/Jenkins/jobs/unity-windows/workspace
The important parts are on lines 11 - 13. Even though I have specified a project path of “unity-web\workspace” and Unity reports it has successfully changed the project path to “unity-web\workspace” it then reports it is using “unity-windows\workspace”. I know this is a problem because my Windows build process shows the following:
BATCHMODE ARGUMENTS:
C:\Program Files (x86)\Unity-4.5\Editor\Unity.exe
-projectPath
C:\Jenkins\jobs\unity-windows\workspace
-quit
-batchmode
-nographics
-logFile
C:\Jenkins\jobs\unity-windows\workspace\bin\build.log
-buildWindowsPlayer
C:\Jenkins\jobs\unity-windows\workspace\bin\my-game.exe
Successfully changed project path to: C:\Jenkins\jobs\unity-windows\workspace
C:/Jenkins/jobs/unity-windows/workspace
It looks like another Unity instance is running with this project open.
Multiple Unity instances cannot open the same project.
Project: C:/Jenkins/jobs/unity-windows/workspace
(Filename: C:/BuildAgent/work/d63dfc6385190b60/Editor/Src/Application.cpp Line: 251)
Aborting batchmode due to failure:
Fatal error! It looks like another Unity instance is running with this project open.
Multiple Unity instances cannot open the same project.
Project: C:/Jenkins/jobs/unity-windows/workspace
Why does Unity occasionally use the wrong project path and how can I force it to always use the correct one?