I try to programmatic add the reference of dll into csproj file at time of installation service through the MSI Installer.
<Reference Include="TestProject">
<HintPath>..\..\TestProject.dll</HintPath>
</Reference>
I put below line of source code of add node into
protected override void OnAfterInstall(IDictionary savedState)
of ProjectInstaller.cs
var refnode = xml.CreateElement("Reference");
var attribute = xml.CreateAttribute("Include", null);
attribute.Value = "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);
Output of code
<Reference Include="TestProject" xmlns="">
<HintPath>..\..\TestProject.dll</HintPath>
</Reference>
But the source code add xmlns=""
more attribute into Reference element. what is wrong in this code how I will remove xmlns=""
attribute because csproj file not take custom attribute.