Reputation: 3175
I am not a big expert in deploying, so asking y'all about one thing I couldn't find in internet anywhere.
Let's suppose I have a project written in .net core, preferably aspnet core. I am using also TFS (VSTS).
Ideally I need to include a build number (or version number, I don't know how to be more precise) into my version of the software, which I can see from 'About Us' page. Ideally, I suppose, it should be a check-in number of current code version. But I guess it might be any other great solution exists.
Advice needed.
Upvotes: 0
Views: 1161
Reputation: 51183
The simplest way is using the build number as your version number. There is a Global .NET Versioning Strategy: AssemblyInformationalVersion. You could use this strategy to add versioning to your software. You could use a powershell script to version to your assemblies.
The powershell script will do the magic in the background to replace all versioning values for AssemblyVersion, AssemblyFileVersion and AssemblyInformationalVersion in the Assembly Info files, based on this product version. The product version will be passed as a whole to the AssemblyVersion and the AssemblyInformationalVersion attributes. The AssemblyFileVersion will be replaced with a full version number which will consist of the major and minor version number of the product version, a Julian based date and an incremental build number.
For the meaning of Assembly File Version = 2.7.15169.03
- 2 => taken from “Major” product version
- 7 => taken from “Minor” product version
- 15169 => generated by build process: “15” = year 2015, “169” = day of year 2015
- 3 => third build, run on day 169 in year 2015
For more details you could take a look at this great post: TFS Build 2015 … and versioning! and this similar topic vNext Build Awesomeness – Managing Version Numbers
Update
You could use $(Build.SourceVersion)
in your build number format to include the changeset info such as
$(BuildDefinitionName)_$(date:yyyyMMdd)_$(Build.BuildId).$(Build.SourceVersion)$(rev:.r)
However this $(Build.SourceVersion) only works when builds were triggered automatically on commit (on Continuous integration).Cause when you run a manual build you have to enter the Source Version field in order for it to populate. More details please check this: Build.SourceVersion is blank in VSO vNext Build
You could also use PowerShell script to get the Source Version Changeset number and apply it in your build number or AssemblyInfo.
Upvotes: 1