KirillOsenkov / MSBuildStructuredLog

A logger for MSBuild that records a structured representation of executed targets, tasks, property and item values.
MIT License
1.46k stars 198 forks source link

Improve the exception when a property is not found #508

Closed 0xced closed 3 years ago

0xced commented 3 years ago

FindPropertyInfo is used at three different places but the result was only checked in one place (the SetPropertyValue method). Now the result is checked inside the FindPropertyInfo method itself to make sure we have a proper exception rather than a NullReferenceException when accessing propertyInfo.PropertyType on a null propertyInfo.

Also, the message of the exception has been improved to give a hint about the probable root cause of the issue.

Finally, wrap Program.Run in a try/catch so that we can read the exception and decide to close the console by pressing a key.