This issue is about 2 years old now (for me). Current answer is: can't be done.
I'm using git
, but I believe this doesn't depend on which one you're using, even if it's Asset Server.
Keep in mind I'm following everything in the manual plus what I've found around.
The library rebuild can take anywhere from minutes to even hours, depending on how much Unity thinks it needs to work.
Although this is not a critical issue (it doesn't stop the workflow) it's still huge. We're not fully using git thanks to this issue. It's impractical to go back in history to an old commit or even simply changing a parallel branch can become a nightmare. So we always avoid to do it, unless it's critical.
There are many things that will trigger a library rebuild, here are a few known ones:
- Touching the file. No brainer here. The more you touch, the more time it takes.
- Moving / renaming files outside of Unity. Specially noticeable if they are video files.
- Keeping timestamps in git is not enough. At least in the way I could do it.
- Whenever we checkout in a new machine - this will add an extra library rebuild because eventually have to change back the build platform settings to Android or whatever.
The question is in the title: How to prevent the library to keep rebuilding itself like that?
As for a few plausible expected but invalid answers...
It wouldn't work if I commit the library along because even just checking out an old commit and back to same one before opening Unity will also trigger a library rebuild.
The "Library Network Cache" called "Cache Server" does not solve any of these issues. It does make it faster, some times, specially for checking out on a new machine. But it's still far from good. It still can take up to hours.