title: Using XmlUpdate to set Version information from an Assembly
body: <p>Using MSBuild and MSBuild Community Tasks I am trying to do something very simple:</p>
  
  <ol>
  <li>Get version information from an assembly.</li>
  <li>Update a .nuspec file with that version information.</li>
  </ol>
  
  <p>My MSBuild target looks like this:</p>
  
  <pre><code>&lt;Target Name="Package"&gt;
    &lt;GetAssemblyIdentity AssemblyFiles="%(PackageDir.FullPath)\MyAssembly.dll"&gt;
      &lt;Output TaskParameter="Assemblies" ItemName="AssemblyIdentity" /&gt;
    &lt;/GetAssemblyIdentity&gt;
    &lt;XmlUpdate 
       Prefix="nu"
       Namespace="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"
       XmlFileName="%(PackageDir.FullPath)\MyAssembly.nuspec"
       XPath="/nu:package/nu:metadata/nu:version"
       Value="%(AssemblyIdentity.Version)" /&gt;
  &lt;/Target&gt;
  </code></pre>
  
  <p>The problem I'm having is that the NuGetPack task runs TWICE: The first time, the Assembly version is missing but the paths are correct, the second time the Assembly version is correct but the paths are missing!</p>
  
  <p>Here is the output:</p>
  
  <pre><code>Updating Xml Document "D:\MyProject\package\MyAssembly.nuspec".
      1 node(s) selected for update.
    XmlUpdate Wrote: "".
    Updating Xml Document "\MyAssembly.nuspec".
  D:\MyProject\MyProject.build(64,9): error : Could not find file
   'D:\MyAssembly.nuspec'.
  Done Building Project "D:\MyProject\MyProject.build" (Package target(s)
  ) -- FAILED.
  </code></pre>
  
  <p>I also tried using the NuGetPack task, but got similar results. Help is greatly appreciated!</p>