tag:help.appveyor.com,2012-11-13:/discussions/questions/32509-force-pre-release-version-number-in-branchAppVeyor: Discussion 2019-03-04T21:01:25Ztag:help.appveyor.com,2012-11-13:Comment/467385692019-01-02T10:04:28Z2019-01-02T10:04:29ZForce Pre-release version number in branch<div><p>Hi,<br>
New to yml files and AppVeyor but so far the experience has been awesome. My question relates to how I can setup the version number depending on the branch type. e.g. master always builds release versions, but any other branch will change the patch and append a pre-release value so that when the nuget package is built, it deploys to NuGet.org and will be displayed as a pre-release package.<br>
I don't want to manually have to change the file version or package versions as part of checkins, etc.<br>
Is this possible, can someone help with the yml too?<br>
thanks in advance.</p></div>Allantag:help.appveyor.com,2012-11-13:Comment/467385692019-01-02T17:29:46Z2019-01-02T17:29:46ZForce Pre-release version number in branch<div><p>Hi, Allan.<br>
It's hard to give too specific advice without seeing your current configuration file but you can find information about using the build worker API to alter build details <a href="https://www.appveyor.com/docs/build-worker-api/#update-build-details">here</a>.<br>
You could combine that with some logic that checks for the value of <code>APPVEYOR_REPO_BRANCH</code> (one of the <a href="https://www.appveyor.com/docs/environment-variables/">environment variables</a> set by AppVeyor for every build) and renames version accordingly.<br>
Or, instead of including logic to determine which branch is building, you could make use of conditional build configuration as described in <a href="https://www.appveyor.com/blog/2017/08/01/sharing-configuration-between-branches-in-appveyor-yml/">this blog post</a>.<br>
Here is a hypothetical example.</p>
<pre>
<code>for:
-
branches:
only: master
before_build:
- appveyor UpdateBuild -Version <release-version>
-
branches:
only: /dev-.*/
before_build:
- appveyor UpdateBuild -Version <pre-release-version></code>
</pre></div>Owen McDonnell