Make sure optional external project are not added.

Also add test to make sure it is case.