[Core] Improved mhutch's NRE fix in TargetFRamework.ProfileMatchesPattern()