Remove xmlns=“” attribute when adding Reference element into csproj

Bizzy

New Member
I try to programmatic add the reference of dll into csproj file at time of installation service through the MSI Installer. \[code\]<Reference Include="TestProject"> <HintPath>..\..\TestProject.dll</HintPath></Reference>\[/code\]I put below line of source code of add node into
\[code\]protected override void OnAfterInstall(IDictionary savedState)\[/code\] of ProjectInstaller.cs\[code\]var refnode = xml.CreateElement("Reference");var attribute = xml.CreateAttribute("Include", null);attribute.Value = "http://stackoverflow.com/questions/10915454/TestProject";refnode.Attributes.Append(attribute);var hintPath = xml.CreateNode(XmlNodeType.Element, "HintPath", null);hintPath.InnerText = "..\..\TestProject.dll";refnode.AppendChild(hintPath);xml.AppendChild(refnode);xml.Save(file);\[/code\]Output of code \[code\]<Reference Include="TestProject" xmlns=""> <HintPath>..\..\TestProject.dll</HintPath></Reference>\[/code\]But the source code add \[code\]xmlns=""\[/code\] more attribute into Reference element. what is wrong in this code how I will remove \[code\]xmlns=""\[/code\] attribute because csproj file not take custom attribute.
 
Back
Top