anchor.diff:                               @"^v(?<maj>\d+)\.(?<min>\d+)\.(?<rev>\d+)(?<pre>-\w+\d*)?-(?<num>\d+)-g(?<sha>[a-z0-9]+)$",
                                RegexOptions.IgnoreCase)
                         .Groups
  +
       let getMatch (name:string) = result.[name].Value
   
  -    let major, minor, revision, preReleaseSuffix, commitsNum, sha =
  -        getMatch "maj" |> int, getMatch "min" |> int, getMatch "rev" |> int, getMatch "pre", getMatch "num" |> int, getMatch "sha"
  -
  -    
  +    { major = getMatch "maj" |> int
  +      minor = getMatch "min" |> int
  +      revision = getMatch "rev" |> int
  +      preSuffix = getMatch "pre"
  +      commitsNum = getMatch "num" |> int
  +      sha = getMatch "sha"
  +      buildNumber = buildNumber
  +    }
  +
  +type BuildVersionInfo = { assemblyVersion:string; fileVersion:string; infoVersion:string; nugetVersion:string; 
  +                          source: Option<BuildVersionCalculationSource> }
  +let calculateVersion source =
  +    let s = source
  +    let (major, minor, revision, preReleaseSuffix, commitsNum, sha, buildNumber) =
  +        (s.major, s.minor, s.revision, s.preSuffix, s.commitsNum, s.sha, s.buildNumber)
  +
       let assemblyVersion = sprintf "%d.%d.0.0" major minor
       let fileVersion = sprintf "%d.%d.%d.%d" major minor revision buildNumber
       
       // If number of commits since last tag is greater than zero, we append another identifier with number of commits.
       // The produced version is larger than the last tag version.
  -    // If we are on a tag, we use version specified modification.
  +    // If we are on a tag, we use version without modification.
       // Examples of output: 3.50.2.1, 3.50.2.215, 3.50.1-rc1.3, 3.50.1-rc3.35
       let nugetVersion = match commitsNum with
                          | 0 -> sprintf "%d.%d.%d%s" major minor revision preReleaseSuffix
  
positive.code: let solutionsToBuild = !! "Src/All.sln"
  let bakFileExt = ".orig"
  
  type BuildVersionInfo = { assemblyVersion:string; fileVersion:string; infoVersion:string; nugetVersion:string }
  let calculateVersionFromGit buildNumber =
      // Example of output for a release tag: v3.50.2-288-g64fd5c5b, for a prerelease tag: v3.50.2-alpha1-288-g64fd5c5b
      let desc = Git.CommandHelper.runSimpleGitCommand "" "describe --tags --long --match=v*"
  
  
negative.code:                       | 0 -> nugetVersion
                        | _ -> sprintf "%s-%s" nugetVersion sha
  
      { assemblyVersion=assemblyVersion; fileVersion=fileVersion; infoVersion=infoVersion; nugetVersion=nugetVersion; 
        source = Some source }
  
  // Calculate version that should be used for the build. Define globally as data might be required by multiple targets.
  // Please never name the build parameter with version as "Version" - it might be consumed by the MSBuild, override 
  // the defined properties and break some tasks (e.g. NuGet restore).
  let mutable buildVersion = match getBuildParamOrDefault "BuildVersion" "git" with
                             | "git"       -> getBuildParamOrDefault "BuildNumber" "0"
                                              |> int
                                              |> getVersionSourceFromGit
                                              |> calculateVersion
  
                             | assemblyVer -> { assemblyVersion = assemblyVer
                                                fileVersion = getBuildParamOrDefault "BuildFileVersion" assemblyVer
                                                infoVersion = getBuildParamOrDefault "BuildInfoVersion" assemblyVer
                                                nugetVersion = getBuildParamOrDefault "BuildNugetVersion" assemblyVer
                                                source = None }
  
  let addBakExt path = sprintf "%s%s" path bakFileExt
  
  