Several people have written our feedback alias with problems using the AssemblyInfoTask when the projects are under source code control. When the files are checked in the AssemblyInfo files are read-only, and the task fails with an error that the file can't be updated.

The best way to handle this is to check the AssemblyInfo files out before running the AssemblyInfoTask. After the build completes you can then either revert the files, or check them back in with the updated version numbers.

To check the files out and then check them back in using Team Foundation Server add the following lines to your TFSProj file after the <Imports> line for Microsoft.VersionNumber.targets:

<Target Name="AfterGet" Condition="'$(IsDesktopBuild)'!='true'">
     <
Exec WorkingDirectory="$(SolutionRoot)" Command="&quot;$(TeamBuildRefPath)\..\tf.exe&quot;
    
checkout /recursive $(AssemblyInfoFiles)"
/>
</
Target>

<Target Name="AfterCompile" Condition="'$(IsDesktopBuild)'!='true'">
     <
Exec WorkingDirectory="$(SolutionRoot)" Command="&quot;$(TeamBuildRefPath)\..\tf.exe&quot;
    
checkin /comment:&quot;Auto-Build: Version Update&quot; /noprompt /override:&quot;Auto-Build:
     Version Update
&quot; /recursive $(AssemblyInfoFiles)"
/>
</
Target>

Thanks to Gautam from the Team Build team for this tip!

[ Author: Neil Enns ]