Fix generation of discovery.xml when not created. closes #2281