Fix for #1966, use the preferred-install from the rootPackage config to install the dependencies.
Refactored the code with the switch statement.
Always use rootPackage config
Remove old comment
Merge pull request #2751 from sndpl/issue/1966

Fix for #1966, use the preferred-install from the rootPackage