From 7ddb263e7d323a026c7f50e8082cd996345d7873 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Wed, 28 Feb 2018 21:55:26 +0100 Subject: [PATCH] [xharness] Propagate custom defines to referenced projects as well. Fixes maccore #655. (#3615) The ProtocolTest test is located in the bindings-test assembly, and it requires certain conditional compilation defines to be set in order to behave properly. With this fix we correctly set these defines when cloning the bindings-test project (in addition to when we set the defines for the main project, which is either monotouch-test or linkall for this test). Fixes https://github.com/xamarin/maccore/issues/655. --- tests/xharness/Jenkins.cs | 10 +++++++++- tests/xharness/ProjectFileExtensions.cs | 2 +- tests/xharness/TestProject.cs | 5 +++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/xharness/Jenkins.cs b/tests/xharness/Jenkins.cs index e09d780434..86fd1a5dff 100644 --- a/tests/xharness/Jenkins.cs +++ b/tests/xharness/Jenkins.cs @@ -245,8 +245,16 @@ namespace xharness clone.Xml.AddMonoBundlingExtraArgs (bundling_extra_args, task.ProjectPlatform, configuration); if (!string.IsNullOrEmpty (link_mode)) clone.Xml.SetNode (isMac ? "LinkMode" : "MtouchLink", link_mode, task.ProjectPlatform, configuration); - if (!string.IsNullOrEmpty (defines)) + if (!string.IsNullOrEmpty (defines)) { clone.Xml.AddAdditionalDefines (defines, task.ProjectPlatform, configuration); + if (clone.ProjectReferences != null) { + foreach (var pr in clone.ProjectReferences) { + pr.Xml.AddAdditionalDefines (defines, task.ProjectPlatform, configuration); + pr.Xml.Save (pr.Path); + } + } + + } clone.Xml.SetNode (isMac ? "Profiling" : "MTouchProfiling", profiling ? "True" : "False", task.ProjectPlatform, configuration); if (!debug && !isMac) diff --git a/tests/xharness/ProjectFileExtensions.cs b/tests/xharness/ProjectFileExtensions.cs index 70b15cff3d..d158dd6464 100644 --- a/tests/xharness/ProjectFileExtensions.cs +++ b/tests/xharness/ProjectFileExtensions.cs @@ -661,7 +661,7 @@ namespace xharness continue; var defines = csproj.CreateElement ("DefineConstants", MSBuild_Namespace); - defines.InnerText = value; + defines.InnerText = "$(DefineConstants);" + value; xmlnode.AppendChild (defines); return; } diff --git a/tests/xharness/TestProject.cs b/tests/xharness/TestProject.cs index 9ea37c65b5..0e18547221 100644 --- a/tests/xharness/TestProject.cs +++ b/tests/xharness/TestProject.cs @@ -19,6 +19,8 @@ namespace xharness public bool GenerateVariations = true; public string [] Configurations; + public IEnumerable ProjectReferences; + public TestProject () { } @@ -120,11 +122,14 @@ namespace xharness } doc.ResolveAllPaths (original_path); + var projectReferences = new List (); foreach (var pr in doc.GetProjectReferences ()) { var tp = new TestProject (pr.Replace ('\\', '/')); await tp.CreateCopyAsync (test); doc.SetProjectReferenceInclude (pr, tp.Path.Replace ('/', '\\')); + projectReferences.Add (tp); } + this.ProjectReferences = projectReferences; doc.Save (Path); }