From 76009f43ceb632763105e70482cde1f0e94208d0 Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Wed, 20 Mar 2019 12:36:19 +0100 Subject: [PATCH 1/2] [XHarness] Ensure we do not crash if the framework node is missing. --- tests/xharness/ProjectFileExtensions.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/xharness/ProjectFileExtensions.cs b/tests/xharness/ProjectFileExtensions.cs index dbf8763c9abf..666aa771def5 100644 --- a/tests/xharness/ProjectFileExtensions.cs +++ b/tests/xharness/ProjectFileExtensions.cs @@ -227,7 +227,11 @@ public static void SetTopLevelPropertyGroupValue (this XmlDocument csproj, strin public static void RemoveTargetFrameworkIdentifier (this XmlDocument csproj) { - RemoveNode (csproj, "TargetFrameworkIdentifier"); + try { + RemoveNode (csproj, "TargetFrameworkIdentifier"); + } catch { + // ignore exceptions, if not present, we are not worried + } } public static void SetAssemblyName (this XmlDocument csproj, string value) From 5917fb44a97cd6f9fc628c2ed3566ae5e3137f85 Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Wed, 20 Mar 2019 12:48:33 +0100 Subject: [PATCH 2/2] Ensure we do not crash when Info.plist is missing. --- tests/xharness/ProjectFileExtensions.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/xharness/ProjectFileExtensions.cs b/tests/xharness/ProjectFileExtensions.cs index 666aa771def5..7d187a5b41a6 100644 --- a/tests/xharness/ProjectFileExtensions.cs +++ b/tests/xharness/ProjectFileExtensions.cs @@ -553,13 +553,15 @@ static void FindAndReplace (XmlNodeList nodes, string find, string replace) public static void FixInfoPListInclude (this XmlDocument csproj, string suffix) { var import = csproj.SelectSingleNode ("/*/*/*[local-name() = 'None' and contains(@Include ,'Info.plist')]"); - import.Attributes ["Include"].Value = import.Attributes ["Include"].Value.Replace("Info.plist", $"Info{suffix}.plist"); - var logicalName = import.SelectSingleNode ("./*[local-name() = 'LogicalName']"); - if (logicalName == null) { - logicalName = csproj.CreateElement ("LogicalName", MSBuild_Namespace); - import.AppendChild (logicalName); + if (import != null) { + import.Attributes ["Include"].Value = import.Attributes ["Include"].Value.Replace ("Info.plist", $"Info{suffix}.plist"); + var logicalName = import.SelectSingleNode ("./*[local-name() = 'LogicalName']"); + if (logicalName == null) { + logicalName = csproj.CreateElement ("LogicalName", MSBuild_Namespace); + import.AppendChild (logicalName); + } + logicalName.InnerText = "Info.plist"; } - logicalName.InnerText = "Info.plist"; } public static string GetInfoPListInclude (this XmlDocument csproj)