title: Pre-build MSBuild task to update AssemblyInfo not in sync with built exe
body: <p>I am using a pre-build task in Visual Studio 2008 that invokes msbuild:</p>
  
  <pre><code>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe $(MSBuildProjectDirectory)\version.targets /p:Configuration=$(ConfigurationName)
  </code></pre>
  
  <p>Inside version.targets, I am updating the AssemblyInfo.cs file to replace version information:</p>
  
  <pre><code>   &lt;FileUpdate
          Encoding="ASCII"
          Files="$(MSBuildProjectDirectory)\Properties\AssemblyInfo.cs"
          Regex="AssemblyInformationalVersion\(&amp;quot;.*&amp;quot;\)\]" 
          ReplacementText="AssemblyInformationalVersion(&amp;quot;Product $(ConfigurationString) ($(buildDate))&amp;quot;)]"
      /&gt;
  </code></pre>
  
  <p>When I build the project through Visual Studio 2008, it builds without any problems.</p>
  
  <p>But when I look at the resulting exe's version information, it contains the previous time stamp even though the AssemblyInfo.cs has been changed with the "correct" one.  </p>
  
  <p>It seems that the pre-build's changes aren't seen by the main compilation task and it's always one behind.</p>
  
  <p>Any ideas of what I'm doing wrong?</p>