title: Read AssemblyFileVersion from AssemblyInfo post-compile
body: <p>How can one read the <em>AssemblyFileVersion</em>, or its components <em>AssemblyFileMajorVersion</em>, <em>AssemblyFileMinorVersion</em>, <em>AssemblyFileBuildNumber</em>, <em>AssemblyFileRevision</em>, within the .csproj, following compilation?</p>
  
  <p>I have tried the following which pulls the information from the built assembly:</p>
  
  <pre><code>&lt;Target Name="AfterCompile"&gt;
      &lt;GetAssemblyIdentity AssemblyFiles="$(TargetPath)"&gt;
           &lt;Output
               TaskParameter="Assemblies"
               ItemName="MyAssemblyIdentities"/&gt;
      &lt;/GetAssemblyIdentity&gt;
      &lt;Message Text="AssemblyVersion = %(MyAssemblyIdentities.Version)" /&gt;
  &lt;/Target&gt;
  </code></pre>
  
  <p>But that retrieves the <em>AssemblyVersion</em> and not the <em>AssemblyFileVersion</em>.  There does not seem to be a documented metadata entry for the latter.  I also tried:</p>
  
  <pre><code>&lt;Import Project="$(MSBuildExtensionsPath)\ExtensionPack\MSBuild.ExtensionPack.tasks" /&gt;
  &lt;Target Name="AfterCompile"&gt;
      &lt;MSBuild.ExtensionPack.Framework.Assembly TaskAction="GetInfo" NetAssembly="$(TargetPath)"&gt;
          &lt;Output TaskParameter="OutputItems" ItemName="Info" /&gt;
      &lt;/MSBuild.ExtensionPack.Framework.Assembly&gt;
      &lt;Message Text="AssemblyFileVersion = %(Info.FileVersion)" /&gt;
  &lt;/Target&gt;
  </code></pre>
  
  <p>Unfortunately, while this retrieves the correct value, it also file locks the assembly until VS2008 is closed.</p>
  
  <p>Frankly, neither is what I want as I would rather read the information from the AssemblyInfo.cs directly.  However, I cannot figure out how to do that.  I assumed AssemblyInfo in the MSBuild Extensions was one way, but it seems focused on writing to the AssemblyInfo and not retrieving values from it.</p>
  
  <p>How can I best accomplish this?</p>