/// <summary> /// Gets the standard Informational version string. /// If <see cref="SVersion.IsValid"/> is false this throws an <see cref="InvalidOperationException"/>: /// the constant <see cref="InformationalVersion.ZeroInformationalVersion"/> should be used when IsValid is false. /// </summary> /// <param name="commitSha">The SHA1 of the commit (must be 40 hex digits).</param> /// <param name="commitDateUtc">The commit date (must be in UTC).</param> /// <returns>The informational version.</returns> public string GetInformationalVersion(string commitSha, DateTime commitDateUtc) { if (!IsValid) { throw new InvalidOperationException("IsValid must be true. Use InformationalVersion.ZeroInformationalVersion when IsValid is false."); } return(InformationalVersion.BuildInformationalVersion(this, commitSha, commitDateUtc)); }
/// <summary> /// Gets the standard Informational version string. /// If <see cref="SVersion.IsValid"/> is false this throws an <see cref="InvalidOperationException"/>: /// the constant <see cref="InformationalVersion.ZeroInformationalVersion"/> should be used when IsValid is false. /// </summary> /// <param name="commitSha">The SHA1 of the commit (must be 40 hex digits).</param> /// <param name="commitDateUtc">The commit date (must be in UTC).</param> /// <param name="buildInfo"> /// Not null for post-release version. /// <see cref="CIBuildDescriptor.IsValid"/> and <see cref="CIBuildDescriptor.IsValidForShortForm"/> must be true. /// </param> /// <returns>The informational version.</returns> public string GetInformationalVersion(string commitSha, DateTime commitDateUtc, CIBuildDescriptor buildInfo = null) { if (!IsValid) { throw new InvalidOperationException("IsValid must be true. Use CSVersion.InvalidInformationalVersion when IsValid is false."); } var semVer = ToString(CSVersionFormat.Normalized, buildInfo); var nugetVer = ToString(CSVersionFormat.ShortForm, buildInfo); return(InformationalVersion.BuildInformationalVersion(semVer, nugetVer, commitSha, commitDateUtc)); }