Every couple of weeks I get mail from someone who is using the AssemblyInfoTask on a build machine under source control. The question typically goes like this:

I added the .targets file to my project, and it works fine on my dev machine, but doesn't do anything when I'm running it in the build lab. What's wrong? Help!

The reason it "doesn't do anything" is because the default Microsoft.VersionNumber.Targets file includes MSBuild attributes that instruct the build engine to check timestamps on input and output files. These were added because it doesn't make much sense to increment the version number on an assembly if nothing is gettting re-built. This can happen if MSBuild does an incremental build on the project.

In the build lab, however, all of the input files (.cs files, generally) and the output file (assemblyinfo.cs) wind up with the same timestamps when they are synchronized from the soruce code control server.

To resolve this, simply remove the Inputs and Outputs attributes from the <Target> tag in the Microsoft.VersionNumber.Targets file. It should wind up looking like this:

<Target Name="UpdateAssemblyInfoFiles">

[ Author: Neil Enns ]