How To: Remove the Up-To-Date Check From the AssemblyInfoTask

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 ]

Comments (11)

  1. Ron says:

    I removed the Inputs and Outputs attributes from the <Target> tag in the Microsoft.VersionNumber.Targets file.  The major version, minor version, and build number update correctly; however, the revision number remains 0 even after making a change to the source code and rebuilding.

    I have the following entries in the AssemblyInfo.vb file:

    <Assembly: AssemblyFileVersion("")>

    <Assembly: AssemblyVersion("")>

    I have the following entries in the TFSBuild.proj file:







    Adding an <AssemblyRevision>1</AssemblyRevision> tag to the TFSBuild.proj <PropertyGroup> tag made no difference.

    Please advise.

  2. Neil says:

    Ron, are you importing Microsoft.VersionNumber.Targets?

  3. Ron says:

    The issue was caused by the fact that we were not saving the updated AssemblyVersion.vb files back to the source control system.

  4. Ram says:

    Where is the AssemblyInfoTask defined? I can’t find the Microsoft.VersionNumber.Targets file. Is this target file installed in a separate location from the other target files?

  5. Mike Fourie says:

    It gets installed under c:program filesmsbuildassemblyinfotask.


  6. Adrigo says:

    I am creating an continous build environment using CC.NET. CC polls my SVN repo for every 30 seconds, and builds if there any modifications.  

    When I check-out code from the source control repository, I change the version numbers for all AssemblyInfo.cs files in my check-out directory. I commit the changed source back in the repository so that the AssemblyInfo.cs files accurately reflect the correct version.

    But, CC.NET kicks of the check-out again because it obviously assumes that the AssemblyInfo.cs files that it committed just now constitute a change in the repo! The cycle continues ad infinitum.

    Can somebody else tell me how they are managing this ?

  7. alan says:

    attribute magic pro changes and modifys date, time and attributes of files and folders.

  8. Jack says:

    I’m using this Task for code managed by Subversion.  However I am faced with this probelm:

    When the task is used on any project not in source control it operates as normal, i.e. the revision number is only updated when a change is made and a build required.

    However if the task is used on any project under source control, it is run on every build and the Assembly Info updated with each build. Even if no code has been changed.

    Anyone else experience this?

  9. Biggles the Wonder Lama says:

    The output file (assemblyinfo.cs) should not be in revision control.  Only the input files (source, build scripts, configuration files) belong in source control.  The build machine should syncronize with the repository and then build the generated files.

  10. Steven Smith says:

    This afternoon I embarked on a quick (hah!) task to fix a problem with my CC.NET implementation. I&rsquo;m

  11. Jimboh says:

    If the Assembly.cs file is not in source control then where is it ?

Skip to main content