Table of Contents

MSBuild properties

Inputs

Input properties are passed to the Git2SemVer MSBuild task. A property may be defined within a csproj file or on a command line like:

  dotnet build -p:Git2SemVer_UpdateHostBuildLabel=true

Or, in the csproj file like:

  <PropertyGroup>
        :
    <Git2SemVer_UpdateHostBuildLabel>true</Git2SemVer_UpdateHostBuildLabel>
        :
  </PropertyGroup>

The MSBuild input poperties are:

Open Source
Description
Git2SemVer_BuildContext

If set, overrides the host's BuildContext property.

The build context gives context to the build number. On a build system that provides a build number, like TeamCity, it is not required or set to "0". On an uncontrolled host (dev box) it is the host's machine name as the build number only makes sense in the context of that host.

Git2SemVer_BuildIDFormat

If set overrides the build host's BuildIdFormat property to overrides how the host formats build ID

A a dot delimited string of identifiers. Identifiers BUILD_NUMBER and BUILD_CONTEXT are replaced with the values of the host's build number and build contxt.

Example values: BUILD_NUMBER.BUILD_CONTEXT, BUILD_NUMBER.BUILD_CONTEXT, BUILD_NUMBER, or MyBuildId.

Default is build host dependent.

Git2SemVer_BuildNumber

Optional value that overrides the host's BuildNumber property.

Use this to pass in build number from a build system. Not required if using TeamCity.

Git2SemVer_BranchMaturityPattern

Optional regular expression value to map branch name to release and prerelease labels.

Default is ^((?main|release)|(?(main|release)[\\/_]rc)|(?feature)|(?.+))[\\/_]?

The release group is required. All others a prereleases and the group name is the prerelease label.

Git2SemVer_Disable
Set to true to disable Git2SemVer. Default is false.
Git2SemVer_HostType
If set, overrides automatic host detection. Value values are "Uncontrolled", "TeamCity", or "GitHub".
Git2SemVer_ScriptArg
A string made that Git2SemVer passes on for the C# script to use. Not used by Git2SemVer.
Git2SemVer_ScriptPath

Path, relative to the project's folder, to the C# script file. Provided to allow the script file use a custom name and/or be moved to another folder.

Default is Git2SemVer.csx in the project's folder.

Git2SemVer_UpdateHostBuildLabel

Only used if building on a host, such as a TeamCity agent, that supports setting the build's label/version. Then if set to true, and build label will be set to the generated build system version.

Default is false. To update the build system's label set this on the command line or in the csproj file.

Outputs

Git2SemVer's MSBuild task outputs version information to MSBuild properties. Some of these properties are standard MSBuild properties used by the compiler. The custom properties are provided for third party MSBuild task use.

Standard versioning properties

MSBuild standard versioning properties set are:

  • AssemblyVersion
  • FileVersion
  • InformationalVersion
  • PackageVersion
  • Version
  • VersionPrefix
  • VersionSuffix

More information can be found here.

Custom properties

Custom properties set for use by other scripts are:

Property
Description
Git2SemVer_CommitsSinceLastRelease

The count of commits from head to the last release used for versioning. Also known as "commit height".

Commit height is very widely used but not reliable. Consider using Git2SemVer's build number for better traceability.

Not used by Git2SemVer.

Git2SemVer_Output1

An output value that may be set by C# script (context.Outputs.Output1).

Default is an empty string.

Not used by Git2SemVer.

Git2SemVer_Output2

An output value that may be set by C# script (context.Outputs.Output1).

Default is an empty string.

Not used by Git2SemVer.