Skip to content
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

Version Column #82

Open
tb-mtg opened this issue Oct 18, 2019 · 3 comments
Open

Version Column #82

tb-mtg opened this issue Oct 18, 2019 · 3 comments
Labels

Comments

@tb-mtg
Copy link

tb-mtg commented Oct 18, 2019

On the available columns to be displayed, could you introduce a "Version" column that shows the each project's version after the state changes to "BuildDone"?

This would help show any new version's that may have been automatically generated as part of the build.

@StefanKert
Copy link
Owner

Thanks for the idea. Can you give me additional details on what you mean with Version? Are you talking about the AssemblyVersion?

@tb-mtg
Copy link
Author

tb-mtg commented Oct 20, 2019

According to this helpful page, .Net Core uses the project file (.csproj or .vbproj) the Version property (which is made up of VersionPrefix & VersionSuffix properties if Version is not specified) is used to determine the following properties:

  • FileVersion
  • AssemblyVersion
  • InformationalVersion
  • PackageVersion

So all of these properties could be used as optional columns if specified.

A fallback method could be using assembly attributes the reading the project files is not possible or any of the properties above are not specified.

[assembly: AssemblyVersion("1.2.3.4")]
[assembly: AssemblyFileVersion("6.6.6.6")]
[assembly: AssemblyInformationalVersion("So many numbers!")]

@tb-mtg
Copy link
Author

tb-mtg commented Oct 20, 2019

Maybe something like below using an Xml reader may help:

using System.Xml;
using System.Xml.Linq;
using System.Xml.XPath;
var projectPath = "c:\temp\Example.csproj";

var xmlProject = XDocument.Load(projectPath, LoadOptions.PreserveWhitespace);
var defaultNamespace = xmlProject.Root.GetDefaultNamespace();
var defaultNamespacePrefix = "ns";
var xmlNamespaceManager = new XmlNamespaceManager(new NameTable());
xmlNamespaceManager.AddNamespace(defaultNamespacePrefix, defaultNamespace.NamespaceName);

XElement GetPropertyGroupElement(string xElementName) {
  return xmlProject.Root.XPathSelectElement($"{defaultNamespacePrefix}:PropertyGroup/{defaultNamespacePrefix}:{xElementName}", xmlNamespaceManager);
}

var versionPrefix = GetPropertyGroupElement("VersionPrefix")?.Value;
var versionSuffix = GetPropertyGroupElement("VersionSuffix")?.Value;
var version = GetPropertyGroupElement(Program.Version)?.Value ?? versionPrefix + '-' + versionSuffix;

var assemblyVersion = GetPropertyGroupElement("AssemblyVersion")?.Value ?? versionPrefix;
var fileVersion = GetPropertyGroupElement("FileVersion")?.Value ?? assemblyVersion;
var informationalVersion = GetPropertyGroupElement("InformationalVersion")?.Value ?? version;
var packageVersion = GetPropertyGroupElement("PackageVersion")?.Value ?? version;

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

No branches or pull requests

2 participants