TFSVersion Issue

Oct 28, 2010 at 1:16 PM

I'm encountering this issue sporadically and I am hoping to get it resolved once and for all.

Every once in a while I get the following error:

error : No Files specified. Pass an Item Collection of files to the Files property

I believe the collection that is empty is:

  <PropertyGroup>
    <AssemblyInfoSpec>CommonAssemblyInfo.cs</AssemblyInfoSpec>
  </PropertyGroup>

  <ItemGroup>
    <AssemblyInfoFiles Include="$(SolutionRoot)\**\$(AssemblyInfoSpec)"/>
  </ItemGroup>
Re-running the build solves the problem. Of course we don't want any failed builds due to this issue. Any suggestions would be greatly appreciated.
 
Here is the full script versioning support:
 
  <PropertyGroup>
    <AssemblyInfoSpec>CommonAssemblyInfo.cs</AssemblyInfoSpec>
  </PropertyGroup>

  <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="Elapsed"
                                                   StartDate="18 OCT 2010"
                                                   Major="1"
                                                   Minor="2">
      <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>
Coordinator
Oct 28, 2010 at 1:21 PM

Move the ItemGroup into the Target so it is calculated at the appropriate time.

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

Oct 28, 2010 at 5:42 PM

doh!

Thank you so much for pointing out the obvious.