Sdílet prostřednictvím


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

  • Anonymous
    March 30, 2006
    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("1.0.0.0")>
    <Assembly: AssemblyVersion("1.0.0.0")>

    I have the following entries in the TFSBuild.proj file:
    <PropertyGroup>
    <AssemblyMajorVersion>1</AssemblyMajorVersion>
    <AssemblyFileMajorVersion>1</AssemblyFileMajorVersion>
    <AssemblyMinorVersion>0</AssemblyMinorVersion>
    <AssemblyFileMinorVersion>0</AssemblyFileMinorVersion>
    </PropertyGroup>

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

    Please advise.

  • Anonymous
    April 02, 2006
    Ron, are you importing Microsoft.VersionNumber.Targets?

  • Anonymous
    April 05, 2006
    The issue was caused by the fact that we were not saving the updated AssemblyVersion.vb files back to the source control system.

  • Anonymous
    April 11, 2006
    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?

  • Anonymous
    April 17, 2006
    It gets installed under c:program filesmsbuildassemblyinfotask.

    Neil

  • Anonymous
    April 19, 2006
    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 ?

  • Anonymous
    May 08, 2006
    attribute magic pro changes and modifys date, time and attributes of files and folders.

    http://www.yaodownload.com/utilites/file-disk-management/attributemagic/

  • Anonymous
    September 01, 2006
    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?

  • Anonymous
    September 12, 2006
    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.

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

  • Anonymous
    February 01, 2008
    If the Assembly.cs file is not in source control then where is it ?