Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Commit 41e4fe2

Browse files
committed
Strip unnecessary xmlns during merge
This should fix #121 The problem was when we emitted xml elements to be merged into the .targets file, the emit caused xmlns attributes to be added to each element. While I think this is valid XML, it was causing errors when the packages were used with packages.config files. This strips out all the xmlns attributes from the items being merged in, and should fix the issue.
1 parent a13f6e0 commit 41e4fe2

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

source/AndroidSupportTargets.cshtml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
@using System.Linq
22
@using System.IO
33
@using System.Xml.Linq
4+
5+
@functions {
6+
public static void RemoveXmlns(XElement e)
7+
{
8+
e.Name = e.Name.LocalName;
9+
10+
foreach (var node in e.DescendantNodes())
11+
{
12+
var n = node as XElement;
13+
if (n != null)
14+
RemoveXmlns(n);
15+
}
16+
}
17+
}
18+
419
<?xml version="1.0" encoding="utf-8"?>
520
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
621
@if (@Model.MavenArtifacts.Count > 0) {
@@ -28,6 +43,7 @@
2843
XNamespace nsChild = xmlTargets.Root.Name.Namespace;
2944
@Raw("\r\n\r\n");
3045
foreach (var xelem in xmlTargets.Element (nsChild + "Project").Elements ()) {
46+
RemoveXmlns(xelem);
3147
@Raw("\r\n" + xelem.ToString());
3248
}
3349
@Raw("\r\n\r\n");

0 commit comments

Comments
 (0)