forked from dotnet/msbuild
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CombineXmlElements.cs
47 lines (39 loc) · 1.25 KB
/
CombineXmlElements.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using Microsoft.Build.Framework;
using System.Xml.Linq;
namespace Microsoft.Build.Tasks
{
/// <summary>
/// Combines multiple XML elements
/// </summary>
public class CombineXmlElements : TaskExtension
{
/// <summary>
/// The root element name to use for the generated XML string
/// </summary>
public string RootElementName { get; set; }
/// <summary>
/// The XML elements to include as children of the root element
/// </summary>
public ITaskItem [] XmlElements { get; set; }
/// <summary>
/// The generated XML
/// </summary>
[Output]
public string Result { get; set; }
public override bool Execute()
{
if (XmlElements != null)
{
XElement root = new XElement(RootElementName);
foreach (var item in XmlElements)
{
root.Add(XElement.Parse(item.ItemSpec));
}
Result = root.ToString();
}
return !Log.HasLoggedErrors;
}
}
}