tfsversioncheckinassemblyinfo

Update AssemblyInfo.cs version from TFS (Team Foundation Server) when Checking in


As title says. Is there a way to get a value from TFS like a "Build Value" which I could implement in to visual studio Forms Application upon clicking "Check In" in "Team Explorer"?

Found something like this: https://archive.codeplex.com/?p=tfsversioning But looks too big of a project.


Solution

  • Assume you are using the vNext build system (TFS 2015 and later versison), then you can achieve that with CI (Continuous Integration) build.

    1. Install the extension Update AssemblyInfo on TFS
    2. Create a build definition and enable Continuous Integration, add task Update AssemblyInfo
    3. Use the predefined variable Build.BuildNumber to get the build number and set the build number as the file version
    4. Copy below command and save as a PowerShell/cmd script, then add a PowerShell/Command task as the last task to run the script to check in the changes. See Checkin command.

      tf Checkin $source_dir /comment:"Updated AssemblyInfo.cs version" /noprompt /force /bypass /override:"bypass checkin policies"
      

    Thus the build definition will be triggered once you check in changes and the AssemblyInfo.cs version will be updated automatically with the build number and the updated AssemblyInfo.cs file will be checked in once the build completed.

    Reference below threads:

    enter image description here