<pre>/// <summary> /// Remove lines from the manifest that contain filenames that do not /// exist in the addin bin folder /// </summary> /// <param name="manifest">Manifest file to edit</param> private static void SanitizeManifestToMatchBin(string manifest, string addInBinFolder) { // load manifest XDocument xDoc = XDocument.Load(manifest); xDoc.Root.Attribute(XNamespace.Xmlns + "asmv2").Remove(); XNamespace ns = "urn:schemas-microsoft-com:asm.v2"; // remove any files from dependentAssembly/codebase that do not exist in the bin folder xDoc.Descendants(ns + "dependentAssembly") .Where(x => (string)x.Attribute("dependencyType") == "install" && File.Exists(addInBinFolder + "\\" + (string)x.Attribute("codebase").Value) == false) .Select(x => x.Parent) .Remove(); //xDoc.Descendants(ns + "file") // .Where(x => File.Exists(addInBinFolder + "\\" + (string)x.Attribute("name").Value) == false) // .Select(x => x) // .Remove(); //xDoc.Descendants(ns + "file").Remove(); xDoc.Save(manifest); }
xDoc.Root.Attribute(XNamespace.Xmlns + "asmv2").Remove(); //is throwing null reference exception.
<pre><asmv1:assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd" manifestVersion="1.0" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:co.v1="urn:schemas-microsoft-com:clickonce.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:co.v2="urn:schemas-microsoft-com:clickonce.v2">
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)