Skip to content

Allow configuring AssemblyInformationalVersion contents #368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
JakeGinnivan opened this issue Feb 15, 2015 · 6 comments
Closed

Allow configuring AssemblyInformationalVersion contents #368

JakeGinnivan opened this issue Feb 15, 2015 · 6 comments

Comments

@JakeGinnivan
Copy link
Contributor

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

@robdmoore
Copy link

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.

@deyvsh
Copy link

deyvsh commented May 1, 2015

+1

@veccie
Copy link

veccie commented Jul 26, 2015

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? 😃

@JakeGinnivan
Copy link
Contributor Author

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

@veccie
Copy link

veccie commented Jul 26, 2015

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.

@JakeGinnivan
Copy link
Contributor Author

Closed via #660

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants