Table of Contents

Interface IVersionGeneratorInputs

Namespace
NoeticTools.Git2SemVer.Framework.Generation
Assembly
NoeticTools.Git2SemVer.Framework.dll

Inputs into the MSBuild task read from MSBuild properties.

public interface IVersionGeneratorInputs

Properties

BranchMaturityPattern

Optional input MSBuild Git2SemVer_BranchMaturityPattern property. Sets the regular expression pattern that determines build maturity (prerelease label).

string BranchMaturityPattern { get; }

Property Value

string

Remarks

The default pattern is: ^((?<release>main|release)|(?<beta>feature)|(?<alpha>.+))[\\/_]?.

The groups are evaluated left to right, the first match is used.

The named group release is required. A match to this group results in a release version. The named groups to the right can use any group name. The group's name is the prerelease label to use.

A catch-all pattern at the end (e.g: alpha) is required. If no match is found a prerelease label of "UNKNOWN_BRANCH" is used.

BuildContext

Build context. Provides context or extension to build number.

string BuildContext { get; }

Property Value

string

Remarks

MSBuild property: Git2SemVer_BuildContext.

BuildIdFormat

string BuildIdFormat { get; }

Property Value

string

BuildNumber

Optional input MSBuild Git2SemVer_BuildContext property.

string BuildNumber { get; }

Property Value

string

Remarks

If set, used to override the BuildNumber property.

TeamCity

TeamCity provides the build number in an environment variable BUILD_NUMBER which is is automatically read.

GitHub

Currently GitHub does not provide a build number. However, a unique build ID can be constructed from github.run_number and github.run_attempt:

Unique build ID = "<github.run_number>-<github.run_attempt>"

This can be passed to the build in the GitHub workflow yml like this:

- name: Build NetVersionBuilder
  env:
    BUILD_NUMBER: ${{ github.run_number }}-${{ github.run_attempt }}
  run: |
    dotnet build -p:BuildNumber=${{ env.BUILD_NUMBER }}

BuildScriptPath

Required path the C# script file to run.

string BuildScriptPath { get; }

Property Value

string

Remarks

MSBuild property: Git2SemVer_ScriptPath.

HostType

Optional input MSBuild Git2SemVer_HostType property. If set overrides automatic host type detection.

string HostType { get; }

Property Value

string

Remarks

See the build object's HostTypeId property.

IntermediateOutputDirectory

The intermediate output directory (usually 'obj') that the build log and generated versions file are written to.

string IntermediateOutputDirectory { get; }

Property Value

string

ReleaseTagFormat

Optional MSBuild Git2SemVer_ReleaseTagFormat property.

string ReleaseTagFormat { get; }

Property Value

string

Remarks

MSBuild task input.

RunScript

Optional MSBuild Git2SemVer_RunScript property.

bool? RunScript { get; }

Property Value

bool?

Remarks

If set to false prevents the script from being executed. If set to true ensure the script is executed and fail the build if the script is not present. If null (not set) and the script will execute if present but the build will not fail if not present. The default is null.

ScriptArgs

Optional arguments for script use.

string ScriptArgs { get; }

Property Value

string

Remarks

MSBuild property: Git2SemVer_ScriptArg.

SolutionSharedDirectory

string SolutionSharedDirectory { get; }

Property Value

string

SolutionSharedVersioningPropsFile

string SolutionSharedVersioningPropsFile { get; }

Property Value

string

UpdateHostBuildLabel

Option passed to the script to request the script to update a build system's build label.

bool UpdateHostBuildLabel { get; }

Property Value

bool

Remarks

MSBuild property: Git2SemVer_UpdateHostBuildLabel.

Version

Optional input from MSBuild Version property.

string Version { get; }

Property Value

string

Remarks

Not used by Git2SemVer but include for optional use in C# script.

VersionSuffix

Optional input from MSBuild VersionSuffix property.

string VersionSuffix { get; }

Property Value

string

Remarks

If set to release (case-insensitive) forces the version to be a release. Otherwise, if set, forces a prerelease with this as the prerelease label.

If set, BranchMaturityPattern is not used.

VersioningMode

VersioningMode VersioningMode { get; }

Property Value

VersioningMode

WorkingDirectory

The directory that will be used to run git.exe from. This may usually be any folder within the cloned repository directory,

string WorkingDirectory { get; }

Property Value

string

Remarks

The default is for this to be the project's directory. It must be possible to execute git.exe from this directory.

Methods

ValidateScriptInputs(ILogger)

bool ValidateScriptInputs(ILogger logger)

Parameters

logger ILogger

Returns

bool