- Home /
New scripts not found when building in batch mode
We setup an automatic build machine which builds our unity project after each commit. Build runs unity editor with -batchmode flag. Editor fails with "script not found" every time a new script is added to the project, though script is present in the Assets folder. When build is executed again, without any project changes, compilation passes. Seems problem appears only in the batch mode.
How do we force unity to detect new scripts in the project?
Answer by Taphos · Aug 28, 2013 at 09:23 AM
The problem is that unity refreshes asset database only after running -executeMethod in batch mode. The workaround is to run unity twice.
Unity -quit -batchmode
Unity -quit -batchmode -executeMethod "EditorScript.Test"
Unity should refresh before the script execution, I've submitted a bug report
I found this worked for a while, but I've just had it fail on our build machine! The first invocation appeared to find the new files and import them to the asset database, according to the logs, but the second invocation still didn't build the files correctly, and imported them a second time. This has only happened once in hundreds of builds, but it's still rather pathetic that it's not fixed more than two years on.
Answer by Bunny83 · Aug 27, 2013 at 02:14 PM
I think you need: AssetDatabase.Refresh() in your build script.
Well, what ImportAssetOptions have you used? The only reasonable choice would be ImportAssetOptions.ForceSynchronousImport i think. The docs even state that scripts are usually compiled asynchronously in the background.
It fails to compile editor build script itself so AssetDatabase.Refresh() is never actually called. is there a way to refresh database before running build script?