Skip to content

Herbal3d/BuildVersion

Repository files navigation

BuildVersion

BuildVersion is a tool used in some of the Herbal3d projects to embed version information into the libraries and binaries.

The Herbal3d version form is: appVersion-buildDate-gitCommit. Some examples are:

2.3.4-20220423-5687f522
1.0.1-20220102-78ef8857

Thus, looking at this version number one can know when it was built and which Git commit was used to build the library.

This version string kind of complies with the extended version of Semantic Versioning. The appVersion part matches the "major.minor.patch" format while the ending matches the syntax of the "pre-release" identifier but not the semantic interpretation.

BuildVersion takes an application version number, looks at the Git HEAD version, and writes a file named VersionInfo.cs. It can additionally update a AssemblyInfo.cs file with the application version number.

The invocation parameters are:

Parameter Description
--namespace Namespace to use in VersionInfo.cs. Default is "BuildVersion"
--version Version to use. Format is "num.num.num"
-v short form of "--version"
--versionFile name of the version info file to write. Default is "VersionInfo.cs"
--assemblyInfoFile filename of AssemblyInfo.cs to write. If not specified, no file is updated
--gitDir Git directory to look in. Default is "./.git"
--print Disable all file writing and just print the version number
-p Short version of "--Print"
--verbose Print out progress information
--incrementBuild Increment the build/patch number in the specified version number (see below)
--writeAppVersion Write out the final application version to this file (see below)

As an example, for Convoar, performing:

git clone https://github.com/Misterblue/convoar.git
cd convoar
bin/BuildVersion.exe --version $(cat VERSION) \
            --namespace org.herbal3d.convoar \
            --assemblyInfoFile convoar/Properties/AssemblyInfo.cs \
            --versionFile convoar/VersionInfo.cs

This will update the package and application version in AssemblyInfo.cs and also create a VersionInfo.cs file that contains:

// This file is auto-generated by BuildVersion
// Before editting, check out the application's build environment for use of BuildVersion
using System;
namespace BuildVersion {
    public c class VersionInfo {
        public static string appVersion = "2.3.4";
        public static string longVersion = "2.3.4-20220502-a90774dd";
        public static string buildDate = "20220502";
    }
}

There is also a feature to increment the build version number. As noted in the above example, my convention is to have a top-level file name VERSION that contains the current application version number. Using the parameters --incrementBuild and --writeAppVersion can be used to bump the build version number. So, if VERSION contained "2.3.4" before, it would contain "2.3.5" after using both these parameters.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published