Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7968217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:02:34+00:00 2026-06-04T07:02:34+00:00

I’m in the process of learning TFS2010 Team Build, Workflow and MSBuild. I’ve got

  • 0

I’m in the process of learning TFS2010 Team Build, Workflow and MSBuild. I’ve got a general understanding of Workflow and was recently able to do a successful test build.

Now I need some help with keeping build version and assembly versioning in sync. I’ve been reading several blogs by Jim Lamb and John Robbins on this subject however I’m feeling more confused now than when I started. Jim Lamb’s blogs talk about using a custom activity which uses the current date to set the version number and John Robbins’ blog talks about getting the last assembly version and doing everything in MSBuild since there are no extra dependencies.

Currently we are using a 4 place version number such as 3.8.0.2 then we increment the last number for each build. We use this version to synce all the assemblies. We would like to stay with this format and I’d like to handle all my versioning in workflow however I don’t know how to read the last version from an assembly that way. I’m thinking this will require writing a custom activity but what method would I use to read last version?

Thanks in advance!
Jim

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:02:35+00:00Added an answer on June 4, 2026 at 7:02 am

    Stuart Preston explains a simple way to set the assembly info on his blog:
    http://stuartpreston.net/blog/2010/05/02/simple-assembly-versioning-with-team-build-2010/

    Edit:

    Above link is dead, here is the cached version:

    Posted by Stuart Preston on May 2, 2010 under Team Foundation Server

    There are many more sophisticated ways of achieving this but none seemed to give me exactly what I wanted, so here I present yet another way of doing assembly versioning with Team Build 2010. I wanted my Team Build number to exactly match that of my assembly versions (and not be derived), like this:

    (image)

    So here’s how I do it. To start off with I customise the BuildNumber format within my build definition:

    (image)

    In my case, I decided to customize it so that the Major and Minor version numbers “0.1” were added explicitly. This lets me control the first two parts of the version number which is what I want to achieve. I also added the macros $(Month)$(DayOfMonth) with a 1 in front of it. For the 2nd May 2010 this would generate a number 10502. (The reason I don’t use the full year here is that for today it would generate a build number of 100502 and a file version number cannot be higher than 65335).

    When I decide to work on version 0.2, 0.3 or 1.0 all I have to do is increment the Build Number here and save the definition, I’m also happy to increment the number when the year changes. I said it was simple!

    The final part of the build number format was left as-is (i.e. the Revision number that increments by 1 with each build on that day and resets for the next day).

    Now all we need to do is retrieve this version number when MSBuild is run against the solution, split the version number and take the numeric portion into the Properties\AssemblyVersion.cs file (you will need to comment out the AssemblyFileVersion line in that file first and check it in).

    Here’s the fragment that you’ll need to insert in your .csproj file (you’ll have to check it out then open it in Notepad or your favourite text editor).

    <UsingTask
        TaskName="Microsoft.TeamFoundation.Build.Tasks.GetBuildProperties"
        AssemblyFile="$(MSBuildProgramFiles32)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.Build.ProcessComponents.dll"
      Condition="' $(BuildUri) '!='  '"/>
    
    <Target Name="BeforeBuild" Condition="' $(BuildUri) '!='  '">
      <GetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildUri)">
        <Output TaskParameter="BuildNumber" PropertyName="BuildNumber" />
      </GetBuildProperties>
    
      <PropertyGroup>
        <BuildNumberSplitLocation>$([MSBuild]::Add($(BuildNumber.LastIndexOf('_')),1))</BuildNumberSplitLocation>
      </PropertyGroup>
    
      <ItemGroup>
        <AssemblyVersionLines Include="[assembly:AssemblyFileVersion(&quot;$(BuildNumber.Substring($(BuildNumberSplitLocation)))&quot;)]" />
      </ItemGroup>
    
      <Exec Command="attrib -r &quot;$(ProjectDir)\Properties\AssemblyInfo.cs&quot;" ContinueOnError="false" />
      <Message Text="Lines being added: @(AssemblyVersionLines)" Importance="high" />
      <WriteLinesToFile File="$(ProjectDir)\Properties\AssemblyInfo.cs" Lines="@(AssemblyVersionLines)" />
    </Target>
    

    (End of reference)

    He modifies the csproj file to update the AssemblyInfo.cs file before build with values passed in by TFS so that the assembly is versioned according to a permutation of MMDDRev

    Your situation is a bit different in that you’d like a custom build number. To do that, you could modify the BuildNumberFormat to be 3.8.0.$(Rev:.r). Since the revision is the only thing changing, TFS will automagically increment it for you.

    If you ever want to update the 3.8.0. portion, you can again edit the Build Number Format manually. Otherwise you’ll need a solution for storing & parsing the build number as part of the BeforeBuild task in your csproj.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
i got an object with contents of html markup in it, for example: string
I have thousands of HTML files to process using Groovy/Java and I need to
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.