Make OptimizeCommand backward compatible

Changed new implementation in OptimizeCommand to be backward compatible with old versions of the framework that do not specify providers or files in the compile config
This needs to be removed now. The commits should be squashed after too.