[Core] Fix a null reference exception handling MSBuild errors

We need to add tests on this to make sure we handle the various cases correctly.