I add XmlElemnt to csproj file from another file:
//load the orginal file
XmlDocument xd = new XmlDocument();
xd.Load(fileName);
//load the csproj file to setting
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(project.FullName);
//copy a XmlNode from the orginal file
XmlNode copiedNode = xmlDoc.ImportNode(xd.SelectSingleNode(nodeName), true);
//add the XmlNode to the csproj file
xmlDoc.DocumentElement.InsertAfter(copiedNode,xmlDoc.GetElementsByTagName(nodeName).Item(0));
and the source code add automatically the attribute xmlns="" to the added node:
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'AAA|x86'" xmlns="">
I see a similar issue in the post: Remove xmlns=“” attribute when adding Reference element into csproj. The solution there is to add namespace, but I don't find how to add namespace to my code.
How can I do that? Or- Is there other way to avoid the adding of the xmlns attribute?