问题
I have configured my git repository in VSTS with the GitFlow repository.
I have a master branch with a dotnet core project, and a release branch called 'Release/1.0.0'. When I create a pull-request and merge the release/1.0.0 branch back to master, it does not increment it's version number to 1.0.0. Instead, it's increasing the version number from 0.1.0 (the base fallback) to 0.1.1.
Build log:
Calculating base versions
Fallback base version: 0.1.0 with commit count source xx
Git tag '0.1.0': 0.1.0 with commit count source xx
Base version used: Git tag '0.1.0': 0.1.0 with commit count source xx
However, the commit label is Merge branch Release/1.0.0 to master. And the branch being merged is tagged as 1.0.0.
I am using GitVersion default settings. I am using the GitVersion VSTS task.
This is the gitversion configuration:
assembly-versioning-scheme: MajorMinorPatch
mode: ContinuousDelivery
branches: {}
ignore:
sha: []
What should i do to automatically set the version of the master branch to the versionnumber that is being merged?
Update: I found out what was going "wrong".
Releases were merged back as pull requests. This will set the commit message to Merge PR #### . However, the MergeMessageBaseVersionStrategy of gitversion can not handle this. If i merge the release back as a regular merge, the version number is increased.
回答1:
You should add the GitVersion task in the CI build for master
branch (or queue build after the PR is completed) instead of PR build validation.
Since the PR build validation is triggered before release/1.0.0
branch really merge into master
, so Gitversion will detect the version from master
branch (such as version in AssemblyInfo.cs
file).
If you add the GitVersion task in CI build (after the release/1.0.0
branch merged into master
branch), then Gitversion will detect the version major.minor.patch=1.0.0 from release/1.0.0
branch.
来源:https://stackoverflow.com/questions/47062391/how-to-make-the-gitversion-vsts-increment-release-number-on-master