This project is read-only.

XmlFile does not appear to be persisting updates

May 10, 2011 at 8:11 PM

Running the following snippet of test code I see that everything logs as being successful but I am not seeing any changes in the actual file after the build completes.  Is there a flush or save step that I have somehow overlooked?  I tried going with the simplest XML test cases possible to just get things to work but am striking out.  Also performed some checks (like making sure file was not read only) to address the obvious.  Thanks.

            <Namespaces Include="asmv1Namespace">

             XPath="/asmv1:assembly/entryPoint" />

             Value="Done" />

Build started 5/10/2011 11:37:25 AM.
Project "E:\Testing\dotNET\MSBuild\tester.proj" on node 1 (default targets).
  XmlFile: E:\Testing\dotNET\MSBuild\Excel.AddIn.dll.manifest
  Remove Element: /asmv1:assembly/entryPoint
  XmlFile: E:\Testing\dotNET\MSBuild\Excel.AddIn.dll.manifest
  Set Attribute: Tst123=Done
Done Building Project "E:\Testing\dotNET\MSBuild\tester.proj" (default targets).
May 10, 2011 at 8:41 PM

So, it must be a namepsace issue as I was not paying attention to the attribute on the description element and so setting the XPath to read "/asmv1:assembly/asmv1:description" got that section to work.  I am stumped on the entryPoint element, however.  My online XPath tester locates the node just fine using the "/asmv1:assembly/entryPoint" syntax but the task does not.  I tried forcing a "asmv1" prefix in the query just to be sure but no luck.  Removing all namespaces in the file and just running "clean" does work, however - the element is removed. 

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" xmlns:dsig="" xmlns:co.v2="urn:schemas-microsoft-com:clickonce.v2" xmlns="urn:schemas-microsoft-com:asm.v2" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="" xmlns:co.v1="urn:schemas-microsoft-com:clickonce.v1">
  <description xmlns="urn:schemas-microsoft-com:asm.v1" Tst123="Done">AddIn</description>
  <application />
    <assemblyIdentity name="Client" version="" publicKeyToken="B55A8F" language="neutral" processorArchitecture="msil" />
    <commandLine file="Client.exe" parameters="" />
May 10, 2011 at 9:07 PM

ok - issue resolved.  Switched to another XPath test harness and then brute forced through all the namepsace prefixes.  Turns out that "/asmv1:assembly/asmv2:entryPoint" does the trick.  If someone wants to take the time to explain how that is bases on the XMl file listed above, I woud apprecitate it - and maybe some others would too.  I am no namespace expert but that is definitely an odd corner case, IMO, based on the namespace declarations listed in the file.

May 10, 2011 at 10:37 PM

I think I can see how the XPath namespace issue came about based on closer investigation of the declarations in the xml file:

xmlns="urn:schemas-microsoft-com:asm.v2" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2"

Results in the follwing working in the XML file but requiring that the "asmv2" prefix be place in the XPath query to locate the entryPoint node: