From f35402269b13b605cf5a506dea7613d633a259ad Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Wed, 1 Feb 2017 14:58:45 -0600 Subject: [PATCH] Catch FormatException coming from Convert.ChangeType. (#1635) String.TrimEnd has a new overload for a single char in .NET Core 2.0. However, when MSBuild encounters this new overload first, it throws a FormatException which is not caught - breaking the build. The fix is to catch the FormatException just like an InvalidCastException and continue searching the rest of the reflection MethodInfos for a match. Fix #1634 --- src/XMakeBuildEngine/Evaluation/Expander.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/XMakeBuildEngine/Evaluation/Expander.cs b/src/XMakeBuildEngine/Evaluation/Expander.cs index 0d46d6a4e1c..84583f4ba5e 100644 --- a/src/XMakeBuildEngine/Evaluation/Expander.cs +++ b/src/XMakeBuildEngine/Evaluation/Expander.cs @@ -3608,9 +3608,13 @@ private static object[] CoerceArguments(object[] args, ParameterInfo[] parameter } } } + // The coercion failed therefore we return null catch (InvalidCastException) { - // The coercion failed therefore we return null + return null; + } + catch (FormatException) + { return null; }