Remove reference when removing a shared project

Fixes bug #20398 - After removing a shared project, the project is still
being referenced.