Skip to content

Allow configuring AssemblyInformationalVersion contents #368

Closed

Description

@JakeGinnivan

Add a new branch configuration option assembly-informational-version-format which supports string interpolated values from variables.

For example {majorMinorPatch}.branch.{branch} would use the Branch and MajorMinorPatch variables from the variable provider to create the informational version. This way if you are using ClickOnce (which expects that attribute to contain a valid version) you can override it

Activity

  1. robdmoore commented on Feb 15, 2015

    @robdmoore

    Great idea!

    On 15 Feb 2015, at 7:07 pm, Jake Ginnivan [email protected] wrote:

    Add a new branch configuration option assembly-informational-version-format which supports string interpolated values from variables.

    For example {majorMinorPatch}.branch.{branch} would use the Branch and MajorMinorPatch variables from the variable provider to create the informational version. This way if you are using ClickOnce (which expects that attribute to contain a valid version) you can override it

    —
    Reply to this email directly or view it on GitHub.

  2. deyvsh commented on May 1, 2015

    @deyvsh

    +1

  3. veccie commented on Jul 26, 2015

    @veccie

    Maybe this link can be of use: https://mhusseini.wordpress.com/2014/05/03/fast-named-formats-in-c/

    I've made a quick example to test it which you can see below.

    The only thing I had to change was the Regex pattern, but then it also works great.

    private static readonly Regex RegexFormatArgs = new Regex(@"({)([^}]+)(})", RegexOptions.Compiled);
    

    Example:

        public class SemanticVersion
        {
            public int Major;
            public int Minor;
            public int Patch;
            public string MajorMinorPatch;
            public string PreReleaseTag;
            public int CommitsSinceTag;
            public string Branch;
            public string Sha;
            public string ShaShort;
            public DateTimeOffset CommitDate;
    
            public string ToString(string format)
            {
                return NamedFormat.Format(format, this);
            }
        }
    
        SemanticVersion version = new SemanticVersion
        {
            Major = 2,
            Minor = 4,
            Patch = 1,
            MajorMinorPatch = "2.4.1",
            PreReleaseTag = "beta",
            CommitsSinceTag = 8,
            Branch = "release",
            Sha = "82ff5cc4c3f3ea9aa2711c163fb1edf68abd858b",
            ShaShort = "82ff5cc",
            CommitDate = DateTimeOffset.Now
        };
    
        Debug.WriteLine(version.ToString("{majorMinorPatch}-{PreReleaseTag}.{CommitsSinceTag}.{shaShort}"));
        Debug.WriteLine(version.ToString("{MajorMinorPatch}.{CommitsSinceTag}"));
        Debug.WriteLine(version.ToString("{MajorMinorPatch}-{PreReleaseTag}.{CommitsSinceTag}+Branch.{branch}.Sha.{sha}"));
        Debug.WriteLine(version.ToString("{Major}.{minor}-{PreReleaseTag}"));
    

    All parameters are converted to lowercase so it does not matter how you write them. If a member of SemanticVersion doesn't exist then an ArgumentException is thrown, which of course has to be caught further up the stack.

    The 4 Debug lines above then produces the following output:

    2.4.1-beta.8.82ff5cc
    2.4.1.8
    2.4.1-beta.8+Branch.release.Sha.82ff5cc4c3f3ea9aa2711c163fb1edf68abd858b
    2.4-beta
    

    Pretty cool don't you think? 😃

  4. JakeGinnivan commented on Jul 26, 2015

    @JakeGinnivan
    ContributorAuthor

    Did you want to submit a pull request which sorts this issue?

    The only thing to consider is we want to raise an error if there are any interpolated values which do not exist. For instance {Mjor}.{minor}-{PreReleaseTag} should throw saying Mjor is not a variable

  5. veccie commented on Jul 26, 2015

    @veccie

    Well, I didn't plan to just yet @JakeGinnivan

    I only recently found GitVersion and I don't feel I know the code in depth, so I don't know how to implement this feature without messing something else up. Not yet at least as I still have to investigate a bit more. I just wanted to throw in my example/idea as a part of the solution and hear what people think.

  6. JakeGinnivan commented on Oct 17, 2015

    @JakeGinnivan
    ContributorAuthor

    Closed via #660

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions