superunitybuild / buildtool

A powerful automation tool for quickly and easily generating builds with Unity.
MIT License
1.19k stars 121 forks source link

If first element of build path is an empty string, builds fail with unhelpful error messages #142

Open a-morphous opened 3 months ago

a-morphous commented 3 months ago

Hello, this is a problem I just debugged and solved for myself for a few hours, and thought it'd be useful to share with others:

I was trying to use the buildtool (latest master, downloaded and put into the Packages folder), but all builds were failing with '1 error' and no more specific issues. It turns out that because the version had been blank (I hadn't known you had to generate a new version), and my desired build paths began with $VERSION/, the paths being produced began with /. This overwrote the build directory when using Path.Combine here: https://github.com/superunitybuild/buildtool/blob/99248ede408eb8bba9e328e1fb54de40e4f66498/Editor/Build/BuildProject.cs#L189 and caused all paths to try to be written from /, which fails because Unity doesn't have access to that directory.

I think this is a case where the tool should warn or error out before even reaching the build; if a piece of the path would produce an empty string, I think it's worth noting since those issues can cause paths to behave unexpectedly like I saw.