Confusion with file version.

Nov 13, 2009 at 8:29 PM

Mike,

First, thanks for the awesome work.

Now for the problem: I'm using TfsVersion from the Extension Pack and I'm experiencing a quirk. In Win7 and XP Pro the file version appears to be using elapsed time for the build number even though I scripted it to Date. However the Product Version is set to the right thing.

Here's the interesting part, in Win XP Pro you select a File Version property in the Other version information list it shows the right thing. Windows 7 doesn't expose this 'second' File Version.

Currently the File Version shows 1.0.25577.x, x being the increment. The Product Version is 1.0.091113.x which is exactly what I want. BTW the task is definitely doing something to the File Version, otherwise it would be 1.0.0.0.

Do you have any idea what I'm doing wrong?

Here is the script I've come up with:

  <ItemGroup>
    <AssemblyInfoFiles Include="$(SolutionRoot)\**\$(AssemblyInfoSpec)"/>
  </ItemGroup>

  <Target Name = "BuildNumberOverrideTarget" Condition="'$(IsDesktopBuild)'!='true'">
    <Message Text="Generating version."/>
   
    <MSBuild.ExtensionPack.VisualStudio.TfsVersion TaskAction="GetVersion"
                                                   BuildName="$(BuildDefinition)"
                                                   TfsBuildNumber="$(BuildNumber)"
                                                   VersionFormat="DateTime"                                                                                                     
                                                   DateFormat="yyMMdd"
                                                   PaddingCount="5"
                                                   PaddingDigit="1"
                                                   Major="1"
                                                   Minor="0">     
      <Output TaskParameter="Version" PropertyName="NewVersion" />     
    </MSBuild.ExtensionPack.VisualStudio.TfsVersion>
  </Target>

  <Target Name="AfterGet" Condition="'$(IsDesktopBuild)'!='true'">
    <MSBuild.ExtensionPack.VisualStudio.TfsVersion TaskAction="SetVersion"
                                                   Files="%(AssemblyInfoFiles.Identity)"
                                                   Version="$(NewVersion)"
                                                   AssemblyVersion="1.0.0.0"                                                  
                                                   SetAssemblyVersion="true"/>   
  </Target>

Thanks in advance.

Coordinator
Nov 16, 2009 at 9:19 PM

Weird. Can you post the contents of your AssemblyInfo file.

The task uses a regex AssemblyFileVersion.*\(.*""" + ".*" + @""".*\) on the file. Can you add a Message task to emit $(NewVersion) and see what it lists.

How many files are getting versioned? Are you 100% sure you are looking at the right one?

Using this (note you dont need PaddingCount & PaddingDigit)

 

        <MSBuild.ExtensionPack.VisualStudio.TfsVersion TaskAction="GetVersion"
                                                       BuildName="YOURBUILD"
                                                       TfsBuildNumber="YOURBUILD_20091121.1"
                                                       VersionFormat="DateTime"
                                                       DateFormat="yyMMdd"
                                                       Major="1"
                                                       Minor="0">
            <Output TaskParameter="Version" PropertyName="NewVersion" />
        </MSBuild.ExtensionPack.VisualStudio.TfsVersion>
        <Message Text="$(NewVersion)"/>

I get 1.0.091121.1

 

 

 

 

Nov 17, 2009 at 7:53 PM

Thanks for getting back to me Mike.

I don't believe there is a problem with the task. There are 67 AssemblyInfo.cs files, (Note my ItemGroup for AssemblyInfoFiles.), being updated and as far as I can tell the right thing is being done.

The files have had their AssemblyFileVersion updated correctly: [assembly: AssemblyFileVersion("1.0.091117.1")] and the ProductVersion is showing this version.

Here is a link to an image showing this quirky behavior: FileInfo image. In Windows 7 you only see one 'File Version' and that has the unexpected value.

I'm trying to build without the padding properties and look through the build script to see if some option is causing the problem.

As for the 67 AssemblyInfo files, I understand I should probably do this in a CommonAssemblyInfo but I just started to address build issues here and I'm just learning msbuild and tfsbuild. I'm used to an environment where this sort of thing is a given and is handled by a dedicated build guru.

Nov 18, 2009 at 2:00 PM
Edited Nov 18, 2009 at 2:42 PM

I've figured out the problem. Looking at the build log I found the following csc warning for all assemblies:

CSC : warning CS1607: Assembly generation -- The version '1.0.091116.2' specified for the 'file version' is not in the normal 'major.minor.build.revision' format

Looked up the warning and found the following post from the MSBuild team. Fixing invalid version number problems with the AssemblyInfoTask

Each of the components of the file version are 16 bit ints. Using yyMMdd became unusable 01/2007.