You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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.
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:
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
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.
Activity
robdmoore commentedon Feb 15, 2015
Great idea!
deyvsh commentedon May 1, 2015
+1
veccie commentedon 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.
Example:
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:
Pretty cool don't you think? 😃
JakeGinnivan commentedon Jul 26, 2015
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 sayingMjoris not a variableveccie commentedon 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 commentedon Oct 17, 2015
Closed via #660