Assume you are using the vNext build system (TFS 2015 and later versison), then you can achieve that with CI (Continuous Integration) build.
- Install the extension Update AssemblyInfo on TFS
- Create a build definition and enable
Continuous Integration
, add
task Update AssemblyInfo
- Use the predefined variable
Build.BuildNumber
to get the build
number and set the build number as the file version
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:
