From 7b41f2c47cb69e26021ba31d8b586204e8b4a4e1 Mon Sep 17 00:00:00 2001 From: Nathan Mytelka Date: Fri, 30 Jul 2021 11:58:00 -0700 Subject: [PATCH 01/11] Call XElements "Property" with escaped names --- src/Tasks/CombineTargetFrameworkInfoProperties.cs | 10 +++------- src/Tasks/CombineXmlElements.cs | 10 +++------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/Tasks/CombineTargetFrameworkInfoProperties.cs b/src/Tasks/CombineTargetFrameworkInfoProperties.cs index 612f27d3b88..4ca537abd0f 100644 --- a/src/Tasks/CombineTargetFrameworkInfoProperties.cs +++ b/src/Tasks/CombineTargetFrameworkInfoProperties.cs @@ -2,11 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using Microsoft.Build.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using Microsoft.Build.Shared; using System.Xml.Linq; namespace Microsoft.Build.Tasks @@ -36,9 +32,9 @@ public override bool Execute() { if (PropertiesAndValues != null) { - XElement root = new XElement(RootElementName); + XElement root = new("Property", new XAttribute("Name", EscapingUtilities.Escape(RootElementName))); - foreach (var item in PropertiesAndValues) + foreach (ITaskItem item in PropertiesAndValues) { root.Add(new XElement(item.ItemSpec, item.GetMetadata("Value"))); } diff --git a/src/Tasks/CombineXmlElements.cs b/src/Tasks/CombineXmlElements.cs index c42aed7f1bd..58eeb66d7a5 100644 --- a/src/Tasks/CombineXmlElements.cs +++ b/src/Tasks/CombineXmlElements.cs @@ -2,11 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using Microsoft.Build.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using Microsoft.Build.Shared; using System.Xml.Linq; namespace Microsoft.Build.Tasks @@ -24,7 +20,7 @@ public class CombineXmlElements : TaskExtension /// /// The XML elements to include as children of the root element /// - public ITaskItem [] XmlElements { get; set; } + public ITaskItem[] XmlElements { get; set; } /// /// The generated XML @@ -36,7 +32,7 @@ public override bool Execute() { if (XmlElements != null) { - XElement root = new XElement(RootElementName); + XElement root = new XElement("Property", new XAttribute("Name", EscapingUtilities.Escape(RootElementName))); foreach (var item in XmlElements) { From 8d833fa7a0645527a2ad206d84fd71d8560ffafa Mon Sep 17 00:00:00 2001 From: Nathan Mytelka Date: Wed, 4 Aug 2021 14:50:10 -0700 Subject: [PATCH 02/11] Workaround to prevent SDK breakages --- src/Tasks/CombineTargetFrameworkInfoProperties.cs | 4 +++- src/Tasks/CombineXmlElements.cs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Tasks/CombineTargetFrameworkInfoProperties.cs b/src/Tasks/CombineTargetFrameworkInfoProperties.cs index 4ca537abd0f..35817a553da 100644 --- a/src/Tasks/CombineTargetFrameworkInfoProperties.cs +++ b/src/Tasks/CombineTargetFrameworkInfoProperties.cs @@ -32,7 +32,9 @@ public override bool Execute() { if (PropertiesAndValues != null) { - XElement root = new("Property", new XAttribute("Name", EscapingUtilities.Escape(RootElementName))); + XElement root = RootElementName.StartsWith("PutRootElementAsProperty_") ? + new("Property", new XAttribute("Name", EscapingUtilities.Escape(RootElementName.Substring("PutRootElementAsProperty_".Length)))) : + new(RootElementName); foreach (ITaskItem item in PropertiesAndValues) { diff --git a/src/Tasks/CombineXmlElements.cs b/src/Tasks/CombineXmlElements.cs index 58eeb66d7a5..030990949f9 100644 --- a/src/Tasks/CombineXmlElements.cs +++ b/src/Tasks/CombineXmlElements.cs @@ -32,7 +32,9 @@ public override bool Execute() { if (XmlElements != null) { - XElement root = new XElement("Property", new XAttribute("Name", EscapingUtilities.Escape(RootElementName))); + XElement root = RootElementName.StartsWith("PutRootElementAsProperty_") ? + new("Property", new XAttribute("Name", EscapingUtilities.Escape(RootElementName.Substring("PutRootElementAsProperty_".Length)))) : + new(RootElementName); foreach (var item in XmlElements) { From d0bb260b3dca7ef15cdff0a9723554b7afb5fc19 Mon Sep 17 00:00:00 2001 From: Nathan Mytelka Date: Wed, 4 Aug 2021 15:06:26 -0700 Subject: [PATCH 03/11] Switch switch to optional input --- src/Tasks/CombineTargetFrameworkInfoProperties.cs | 9 +++++++-- src/Tasks/CombineXmlElements.cs | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Tasks/CombineTargetFrameworkInfoProperties.cs b/src/Tasks/CombineTargetFrameworkInfoProperties.cs index 35817a553da..8664cf13015 100644 --- a/src/Tasks/CombineTargetFrameworkInfoProperties.cs +++ b/src/Tasks/CombineTargetFrameworkInfoProperties.cs @@ -22,6 +22,11 @@ public class CombineTargetFrameworkInfoProperties : TaskExtension /// public ITaskItem[] PropertiesAndValues { get; set; } + /// + /// Opts into or out of using the new schema with Property Name=... rather than just specifying the RootElementName. + /// + public bool UseNewSchema { get; set; } = false; + /// /// The generated XML representation of the properties and values. /// @@ -32,8 +37,8 @@ public override bool Execute() { if (PropertiesAndValues != null) { - XElement root = RootElementName.StartsWith("PutRootElementAsProperty_") ? - new("Property", new XAttribute("Name", EscapingUtilities.Escape(RootElementName.Substring("PutRootElementAsProperty_".Length)))) : + XElement root = UseNewSchema ? + new("Property", new XAttribute("Name", EscapingUtilities.Escape(RootElementName))) : new(RootElementName); foreach (ITaskItem item in PropertiesAndValues) diff --git a/src/Tasks/CombineXmlElements.cs b/src/Tasks/CombineXmlElements.cs index 030990949f9..0eb7591a605 100644 --- a/src/Tasks/CombineXmlElements.cs +++ b/src/Tasks/CombineXmlElements.cs @@ -22,6 +22,11 @@ public class CombineXmlElements : TaskExtension /// public ITaskItem[] XmlElements { get; set; } + /// + /// Opts into or out of using the new schema with Property Name=... rather than just specifying the RootElementName. + /// + public bool UseNewSchema { get; set; } = false; + /// /// The generated XML /// @@ -32,8 +37,8 @@ public override bool Execute() { if (XmlElements != null) { - XElement root = RootElementName.StartsWith("PutRootElementAsProperty_") ? - new("Property", new XAttribute("Name", EscapingUtilities.Escape(RootElementName.Substring("PutRootElementAsProperty_".Length)))) : + XElement root = UseNewSchema ? + new("Property", new XAttribute("Name", EscapingUtilities.Escape(RootElementName))) : new(RootElementName); foreach (var item in XmlElements) From c51ae038031026c2416857144330b9543c000f64 Mon Sep 17 00:00:00 2001 From: Nathan Mytelka Date: Wed, 4 Aug 2021 15:49:25 -0700 Subject: [PATCH 04/11] Make enableable via property --- src/Tasks/Microsoft.Common.CurrentVersion.targets | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Tasks/Microsoft.Common.CurrentVersion.targets b/src/Tasks/Microsoft.Common.CurrentVersion.targets index 8cb9228276d..e8c4ec49f16 100644 --- a/src/Tasks/Microsoft.Common.CurrentVersion.targets +++ b/src/Tasks/Microsoft.Common.CurrentVersion.targets @@ -1869,9 +1869,14 @@ Copyright (C) Microsoft Corporation. All rights reserved. + + false + + + XmlElements="@(_TargetFrameworkInfo->'%(AdditionalPropertiesFromProject)')" + UseNewSchema="$(UseNewSchema)"> @@ -1906,9 +1911,14 @@ Copyright (C) Microsoft Corporation. All rights reserved. + + false + + + PropertiesAndValues="@(_AdditionalTargetFrameworkInfoPropertyWithValue)" + UseNewSchema="$(UseNewSchema)"> From 11d458ece36cffde8479c4bce1b99dedc01cd8c6 Mon Sep 17 00:00:00 2001 From: Nathan Mytelka Date: Wed, 4 Aug 2021 20:38:59 -0700 Subject: [PATCH 05/11] Add reference assemblies They didn't autogenerate for some reason with build.cmd. Had to use the CIBuild. --- .../net/Microsoft.Build.Tasks.Core.cs | 2 ++ .../netstandard/Microsoft.Build.Tasks.Core.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/ref/Microsoft.Build.Tasks.Core/net/Microsoft.Build.Tasks.Core.cs b/ref/Microsoft.Build.Tasks.Core/net/Microsoft.Build.Tasks.Core.cs index bbd015301c6..fc849ff6c7b 100644 --- a/ref/Microsoft.Build.Tasks.Core/net/Microsoft.Build.Tasks.Core.cs +++ b/ref/Microsoft.Build.Tasks.Core/net/Microsoft.Build.Tasks.Core.cs @@ -164,6 +164,7 @@ public partial class CombineTargetFrameworkInfoProperties : Microsoft.Build.Task [Microsoft.Build.Framework.OutputAttribute] public string Result { get { throw null; } set { } } public string RootElementName { get { throw null; } set { } } + public bool UseNewSchema { get { throw null; } set { } } public override bool Execute() { throw null; } } public partial class CombineXmlElements : Microsoft.Build.Tasks.TaskExtension @@ -172,6 +173,7 @@ public partial class CombineXmlElements : Microsoft.Build.Tasks.TaskExtension [Microsoft.Build.Framework.OutputAttribute] public string Result { get { throw null; } set { } } public string RootElementName { get { throw null; } set { } } + public bool UseNewSchema { get { throw null; } set { } } public Microsoft.Build.Framework.ITaskItem[] XmlElements { get { throw null; } set { } } public override bool Execute() { throw null; } } diff --git a/ref/Microsoft.Build.Tasks.Core/netstandard/Microsoft.Build.Tasks.Core.cs b/ref/Microsoft.Build.Tasks.Core/netstandard/Microsoft.Build.Tasks.Core.cs index 197ce5ff14b..4e1f6ef0a6c 100644 --- a/ref/Microsoft.Build.Tasks.Core/netstandard/Microsoft.Build.Tasks.Core.cs +++ b/ref/Microsoft.Build.Tasks.Core/netstandard/Microsoft.Build.Tasks.Core.cs @@ -94,6 +94,7 @@ public partial class CombineTargetFrameworkInfoProperties : Microsoft.Build.Task [Microsoft.Build.Framework.OutputAttribute] public string Result { get { throw null; } set { } } public string RootElementName { get { throw null; } set { } } + public bool UseNewSchema { get { throw null; } set { } } public override bool Execute() { throw null; } } public partial class CombineXmlElements : Microsoft.Build.Tasks.TaskExtension @@ -102,6 +103,7 @@ public partial class CombineXmlElements : Microsoft.Build.Tasks.TaskExtension [Microsoft.Build.Framework.OutputAttribute] public string Result { get { throw null; } set { } } public string RootElementName { get { throw null; } set { } } + public bool UseNewSchema { get { throw null; } set { } } public Microsoft.Build.Framework.ITaskItem[] XmlElements { get { throw null; } set { } } public override bool Execute() { throw null; } } From bd7137ad5601575fabb541b1e766a1daefa9bd16 Mon Sep 17 00:00:00 2001 From: Nathan Mytelka Date: Wed, 4 Aug 2021 20:56:02 -0700 Subject: [PATCH 06/11] One other case --- src/Tasks/Microsoft.Common.CrossTargeting.targets | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Tasks/Microsoft.Common.CrossTargeting.targets b/src/Tasks/Microsoft.Common.CrossTargeting.targets index c7d553aecd3..8d86dd591c8 100644 --- a/src/Tasks/Microsoft.Common.CrossTargeting.targets +++ b/src/Tasks/Microsoft.Common.CrossTargeting.targets @@ -29,9 +29,14 @@ Copyright (C) Microsoft Corporation. All rights reserved. + + false + + + XmlElements="@(_TargetFrameworkInfo->'%(AdditionalPropertiesFromProject)')" + UseNewSchema="$(UseNewSchema)"> From ccc6dedfbce2a4a2230870367e0e04078547b95a Mon Sep 17 00:00:00 2001 From: Nathan Mytelka Date: Thu, 5 Aug 2021 13:28:00 -0700 Subject: [PATCH 07/11] Feedback --- documentation/ProjectReference-Protocol.md | 2 ++ src/Tasks/CombineTargetFrameworkInfoProperties.cs | 4 ++-- src/Tasks/CombineXmlElements.cs | 4 ++-- src/Tasks/Microsoft.Common.CrossTargeting.targets | 4 ++-- src/Tasks/Microsoft.Common.CurrentVersion.targets | 8 ++++---- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/documentation/ProjectReference-Protocol.md b/documentation/ProjectReference-Protocol.md index 8cd28cc499d..bc8f63623c7 100644 --- a/documentation/ProjectReference-Protocol.md +++ b/documentation/ProjectReference-Protocol.md @@ -106,6 +106,8 @@ As of MSBuild 16.10, it is possible to gather additional properties from referen These properties will then be gathered via the `GetTargetFrameworks` call. They will be available to the referencing project via the `AdditionalPropertiesFromProject` metadata on the `_MSBuildProjectReferenceExistent` item. The `AdditionalPropertiesFromProject` value will be an XML string which contains the values of the properties for each `TargetFramework` in the referenced project. For example: +> :warning: This format is being changed. Soon, the schema will replace with . You can opt into that behavior early by setting the _UseAttributeForTargetFrameworkInfoPropertyNames property to true. This property will have no effect after the transition is complete. + ```xml diff --git a/src/Tasks/CombineTargetFrameworkInfoProperties.cs b/src/Tasks/CombineTargetFrameworkInfoProperties.cs index 8664cf13015..d1d2370b61b 100644 --- a/src/Tasks/CombineTargetFrameworkInfoProperties.cs +++ b/src/Tasks/CombineTargetFrameworkInfoProperties.cs @@ -25,7 +25,7 @@ public class CombineTargetFrameworkInfoProperties : TaskExtension /// /// Opts into or out of using the new schema with Property Name=... rather than just specifying the RootElementName. /// - public bool UseNewSchema { get; set; } = false; + public bool UseAttributeForTargetFrameworkInfoPropertyNames { get; set; } = false; /// /// The generated XML representation of the properties and values. @@ -37,7 +37,7 @@ public override bool Execute() { if (PropertiesAndValues != null) { - XElement root = UseNewSchema ? + XElement root = UseAttributeForTargetFrameworkInfoPropertyNames ? new("Property", new XAttribute("Name", EscapingUtilities.Escape(RootElementName))) : new(RootElementName); diff --git a/src/Tasks/CombineXmlElements.cs b/src/Tasks/CombineXmlElements.cs index 0eb7591a605..5aa23454efe 100644 --- a/src/Tasks/CombineXmlElements.cs +++ b/src/Tasks/CombineXmlElements.cs @@ -25,7 +25,7 @@ public class CombineXmlElements : TaskExtension /// /// Opts into or out of using the new schema with Property Name=... rather than just specifying the RootElementName. /// - public bool UseNewSchema { get; set; } = false; + public bool UseAttributeForTargetFrameworkInfoPropertyNames { get; set; } = false; /// /// The generated XML @@ -37,7 +37,7 @@ public override bool Execute() { if (XmlElements != null) { - XElement root = UseNewSchema ? + XElement root = UseAttributeForTargetFrameworkInfoPropertyNames ? new("Property", new XAttribute("Name", EscapingUtilities.Escape(RootElementName))) : new(RootElementName); diff --git a/src/Tasks/Microsoft.Common.CrossTargeting.targets b/src/Tasks/Microsoft.Common.CrossTargeting.targets index 8d86dd591c8..9a3c035d5ea 100644 --- a/src/Tasks/Microsoft.Common.CrossTargeting.targets +++ b/src/Tasks/Microsoft.Common.CrossTargeting.targets @@ -30,13 +30,13 @@ Copyright (C) Microsoft Corporation. All rights reserved. Text="Internal MSBuild error: CrossTargeting GetTargetFrameworks target should only be used in cross targeting (outer) build" /> - false + <_UseAttributeForTargetFrameworkInfoPropertyNames Condition="'$(_UseAttributeForTargetFrameworkInfoPropertyNames)' == ''">false + UseAttributeForTargetFrameworkInfoPropertyNames="$(_UseAttributeForTargetFrameworkInfoPropertyNames)"> diff --git a/src/Tasks/Microsoft.Common.CurrentVersion.targets b/src/Tasks/Microsoft.Common.CurrentVersion.targets index e8c4ec49f16..53fc2339f87 100644 --- a/src/Tasks/Microsoft.Common.CurrentVersion.targets +++ b/src/Tasks/Microsoft.Common.CurrentVersion.targets @@ -1870,13 +1870,13 @@ Copyright (C) Microsoft Corporation. All rights reserved. Text="Internal MSBuild error: Non-CrossTargeting GetTargetFrameworks target should not be used in cross targeting (outer) build" /> - false + <_UseAttributeForTargetFrameworkInfoPropertyNames Condition="'$(_UseAttributeForTargetFrameworkInfoPropertyNames)' == ''">false + UseAttributeForTargetFrameworkInfoPropertyNames="$(_UseAttributeForTargetFrameworkInfoPropertyNames)"> @@ -1912,13 +1912,13 @@ Copyright (C) Microsoft Corporation. All rights reserved. - false + <_UseAttributeForTargetFrameworkInfoPropertyNames Condition="'$(_UseAttributeForTargetFrameworkInfoPropertyNames)' == ''">false + UseAttributeForTargetFrameworkInfoPropertyNames="$(_UseAttributeForTargetFrameworkInfoPropertyNames)"> From 05caac0cc31995964b74fdaaa21a41c87efa622e Mon Sep 17 00:00:00 2001 From: Nathan Mytelka Date: Thu, 5 Aug 2021 16:07:27 -0700 Subject: [PATCH 08/11] build --- .../net/Microsoft.Build.Tasks.Core.cs | 4 ++-- .../netstandard/Microsoft.Build.Tasks.Core.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ref/Microsoft.Build.Tasks.Core/net/Microsoft.Build.Tasks.Core.cs b/ref/Microsoft.Build.Tasks.Core/net/Microsoft.Build.Tasks.Core.cs index fc849ff6c7b..e6162435505 100644 --- a/ref/Microsoft.Build.Tasks.Core/net/Microsoft.Build.Tasks.Core.cs +++ b/ref/Microsoft.Build.Tasks.Core/net/Microsoft.Build.Tasks.Core.cs @@ -164,7 +164,7 @@ public partial class CombineTargetFrameworkInfoProperties : Microsoft.Build.Task [Microsoft.Build.Framework.OutputAttribute] public string Result { get { throw null; } set { } } public string RootElementName { get { throw null; } set { } } - public bool UseNewSchema { get { throw null; } set { } } + public bool UseAttributeForTargetFrameworkInfoPropertyNames { get { throw null; } set { } } public override bool Execute() { throw null; } } public partial class CombineXmlElements : Microsoft.Build.Tasks.TaskExtension @@ -173,7 +173,7 @@ public partial class CombineXmlElements : Microsoft.Build.Tasks.TaskExtension [Microsoft.Build.Framework.OutputAttribute] public string Result { get { throw null; } set { } } public string RootElementName { get { throw null; } set { } } - public bool UseNewSchema { get { throw null; } set { } } + public bool UseAttributeForTargetFrameworkInfoPropertyNames { get { throw null; } set { } } public Microsoft.Build.Framework.ITaskItem[] XmlElements { get { throw null; } set { } } public override bool Execute() { throw null; } } diff --git a/ref/Microsoft.Build.Tasks.Core/netstandard/Microsoft.Build.Tasks.Core.cs b/ref/Microsoft.Build.Tasks.Core/netstandard/Microsoft.Build.Tasks.Core.cs index 4e1f6ef0a6c..d010f28ea1f 100644 --- a/ref/Microsoft.Build.Tasks.Core/netstandard/Microsoft.Build.Tasks.Core.cs +++ b/ref/Microsoft.Build.Tasks.Core/netstandard/Microsoft.Build.Tasks.Core.cs @@ -94,7 +94,7 @@ public partial class CombineTargetFrameworkInfoProperties : Microsoft.Build.Task [Microsoft.Build.Framework.OutputAttribute] public string Result { get { throw null; } set { } } public string RootElementName { get { throw null; } set { } } - public bool UseNewSchema { get { throw null; } set { } } + public bool UseAttributeForTargetFrameworkInfoPropertyNames { get { throw null; } set { } } public override bool Execute() { throw null; } } public partial class CombineXmlElements : Microsoft.Build.Tasks.TaskExtension @@ -103,7 +103,7 @@ public partial class CombineXmlElements : Microsoft.Build.Tasks.TaskExtension [Microsoft.Build.Framework.OutputAttribute] public string Result { get { throw null; } set { } } public string RootElementName { get { throw null; } set { } } - public bool UseNewSchema { get { throw null; } set { } } + public bool UseAttributeForTargetFrameworkInfoPropertyNames { get { throw null; } set { } } public Microsoft.Build.Framework.ITaskItem[] XmlElements { get { throw null; } set { } } public override bool Execute() { throw null; } } From 3a5f66e8dad66494844358b86aea263491b09fe6 Mon Sep 17 00:00:00 2001 From: Nathan Mytelka Date: Fri, 6 Aug 2021 10:18:10 -0700 Subject: [PATCH 09/11] Remove escaping from CombineXmlElements --- .../net/Microsoft.Build.Tasks.Core.cs | 1 - .../netstandard/Microsoft.Build.Tasks.Core.cs | 1 - src/Tasks/CombineXmlElements.cs | 12 ++---------- src/Tasks/Microsoft.Common.CrossTargeting.targets | 7 +------ src/Tasks/Microsoft.Common.CurrentVersion.targets | 7 +------ 5 files changed, 4 insertions(+), 24 deletions(-) diff --git a/ref/Microsoft.Build.Tasks.Core/net/Microsoft.Build.Tasks.Core.cs b/ref/Microsoft.Build.Tasks.Core/net/Microsoft.Build.Tasks.Core.cs index e6162435505..0c71f5d7390 100644 --- a/ref/Microsoft.Build.Tasks.Core/net/Microsoft.Build.Tasks.Core.cs +++ b/ref/Microsoft.Build.Tasks.Core/net/Microsoft.Build.Tasks.Core.cs @@ -173,7 +173,6 @@ public partial class CombineXmlElements : Microsoft.Build.Tasks.TaskExtension [Microsoft.Build.Framework.OutputAttribute] public string Result { get { throw null; } set { } } public string RootElementName { get { throw null; } set { } } - public bool UseAttributeForTargetFrameworkInfoPropertyNames { get { throw null; } set { } } public Microsoft.Build.Framework.ITaskItem[] XmlElements { get { throw null; } set { } } public override bool Execute() { throw null; } } diff --git a/ref/Microsoft.Build.Tasks.Core/netstandard/Microsoft.Build.Tasks.Core.cs b/ref/Microsoft.Build.Tasks.Core/netstandard/Microsoft.Build.Tasks.Core.cs index d010f28ea1f..032e84fecf9 100644 --- a/ref/Microsoft.Build.Tasks.Core/netstandard/Microsoft.Build.Tasks.Core.cs +++ b/ref/Microsoft.Build.Tasks.Core/netstandard/Microsoft.Build.Tasks.Core.cs @@ -103,7 +103,6 @@ public partial class CombineXmlElements : Microsoft.Build.Tasks.TaskExtension [Microsoft.Build.Framework.OutputAttribute] public string Result { get { throw null; } set { } } public string RootElementName { get { throw null; } set { } } - public bool UseAttributeForTargetFrameworkInfoPropertyNames { get { throw null; } set { } } public Microsoft.Build.Framework.ITaskItem[] XmlElements { get { throw null; } set { } } public override bool Execute() { throw null; } } diff --git a/src/Tasks/CombineXmlElements.cs b/src/Tasks/CombineXmlElements.cs index 5aa23454efe..214207b1b6e 100644 --- a/src/Tasks/CombineXmlElements.cs +++ b/src/Tasks/CombineXmlElements.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using Microsoft.Build.Framework; -using Microsoft.Build.Shared; using System.Xml.Linq; namespace Microsoft.Build.Tasks @@ -20,12 +19,7 @@ public class CombineXmlElements : TaskExtension /// /// The XML elements to include as children of the root element /// - public ITaskItem[] XmlElements { get; set; } - - /// - /// Opts into or out of using the new schema with Property Name=... rather than just specifying the RootElementName. - /// - public bool UseAttributeForTargetFrameworkInfoPropertyNames { get; set; } = false; + public ITaskItem [] XmlElements { get; set; } /// /// The generated XML @@ -37,9 +31,7 @@ public override bool Execute() { if (XmlElements != null) { - XElement root = UseAttributeForTargetFrameworkInfoPropertyNames ? - new("Property", new XAttribute("Name", EscapingUtilities.Escape(RootElementName))) : - new(RootElementName); + XElement root = new XElement(RootElementName); foreach (var item in XmlElements) { diff --git a/src/Tasks/Microsoft.Common.CrossTargeting.targets b/src/Tasks/Microsoft.Common.CrossTargeting.targets index 9a3c035d5ea..c7d553aecd3 100644 --- a/src/Tasks/Microsoft.Common.CrossTargeting.targets +++ b/src/Tasks/Microsoft.Common.CrossTargeting.targets @@ -29,14 +29,9 @@ Copyright (C) Microsoft Corporation. All rights reserved. - - <_UseAttributeForTargetFrameworkInfoPropertyNames Condition="'$(_UseAttributeForTargetFrameworkInfoPropertyNames)' == ''">false - - + XmlElements="@(_TargetFrameworkInfo->'%(AdditionalPropertiesFromProject)')"> diff --git a/src/Tasks/Microsoft.Common.CurrentVersion.targets b/src/Tasks/Microsoft.Common.CurrentVersion.targets index 53fc2339f87..1262c54d61a 100644 --- a/src/Tasks/Microsoft.Common.CurrentVersion.targets +++ b/src/Tasks/Microsoft.Common.CurrentVersion.targets @@ -1869,14 +1869,9 @@ Copyright (C) Microsoft Corporation. All rights reserved. - - <_UseAttributeForTargetFrameworkInfoPropertyNames Condition="'$(_UseAttributeForTargetFrameworkInfoPropertyNames)' == ''">false - - + XmlElements="@(_TargetFrameworkInfo->'%(AdditionalPropertiesFromProject)')"> From 9db3be180a0cfb5fc44191ad2cac2d1b6c3b308a Mon Sep 17 00:00:00 2001 From: Nathan Mytelka Date: Mon, 9 Aug 2021 16:29:28 -0700 Subject: [PATCH 10/11] Change name --- src/Tasks/CombineTargetFrameworkInfoProperties.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tasks/CombineTargetFrameworkInfoProperties.cs b/src/Tasks/CombineTargetFrameworkInfoProperties.cs index d1d2370b61b..bfd7caae236 100644 --- a/src/Tasks/CombineTargetFrameworkInfoProperties.cs +++ b/src/Tasks/CombineTargetFrameworkInfoProperties.cs @@ -38,7 +38,7 @@ public override bool Execute() if (PropertiesAndValues != null) { XElement root = UseAttributeForTargetFrameworkInfoPropertyNames ? - new("Property", new XAttribute("Name", EscapingUtilities.Escape(RootElementName))) : + new("TargetFramework", new XAttribute("Name", EscapingUtilities.Escape(RootElementName))) : new(RootElementName); foreach (ITaskItem item in PropertiesAndValues) From d9ee0e56bdc209f36db3b98a2694c0a393133d63 Mon Sep 17 00:00:00 2001 From: Forgind Date: Mon, 16 Aug 2021 08:35:47 -0700 Subject: [PATCH 11/11] Update documentation/ProjectReference-Protocol.md --- documentation/ProjectReference-Protocol.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/ProjectReference-Protocol.md b/documentation/ProjectReference-Protocol.md index bc8f63623c7..5e2a138e3d5 100644 --- a/documentation/ProjectReference-Protocol.md +++ b/documentation/ProjectReference-Protocol.md @@ -106,7 +106,7 @@ As of MSBuild 16.10, it is possible to gather additional properties from referen These properties will then be gathered via the `GetTargetFrameworks` call. They will be available to the referencing project via the `AdditionalPropertiesFromProject` metadata on the `_MSBuildProjectReferenceExistent` item. The `AdditionalPropertiesFromProject` value will be an XML string which contains the values of the properties for each `TargetFramework` in the referenced project. For example: -> :warning: This format is being changed. Soon, the schema will replace with . You can opt into that behavior early by setting the _UseAttributeForTargetFrameworkInfoPropertyNames property to true. This property will have no effect after the transition is complete. +> :warning: This format is being changed. Soon, the schema will replace with . You can opt into that behavior early by setting the _UseAttributeForTargetFrameworkInfoPropertyNames property to true. This property will have no effect after the transition is complete. ```xml