diff --git a/Greenshot/Forms/AboutForm.Designer.cs b/Greenshot/Forms/AboutForm.Designer.cs index 1182094ee..ff917cc8c 100644 --- a/Greenshot/Forms/AboutForm.Designer.cs +++ b/Greenshot/Forms/AboutForm.Designer.cs @@ -20,6 +20,7 @@ */ using System.Reflection; +using Greenshot.Helpers; namespace Greenshot { partial class AboutForm { @@ -116,7 +117,7 @@ namespace Greenshot { this.linkLblBugs.Size = new System.Drawing.Size(465, 23); this.linkLblBugs.TabIndex = 8; this.linkLblBugs.TabStop = true; - this.linkLblBugs.Text = "http://getgreenshot.org/tickets/?version=" + Assembly.GetEntryAssembly().GetName().Version; + this.linkLblBugs.Text = "http://getgreenshot.org/tickets/?version=" + EnvironmentInfo.GetGreenshotVersion(true); this.linkLblBugs.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked); // // lblBugs @@ -134,7 +135,7 @@ namespace Greenshot { this.linkLblDonations.Size = new System.Drawing.Size(465, 23); this.linkLblDonations.TabIndex = 10; this.linkLblDonations.TabStop = true; - this.linkLblDonations.Text = "http://getgreenshot.org/support/?version=" + Assembly.GetEntryAssembly().GetName().Version; + this.linkLblDonations.Text = "http://getgreenshot.org/support/?version=" + EnvironmentInfo.GetGreenshotVersion(true); this.linkLblDonations.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked); // // lblDonations @@ -170,7 +171,7 @@ namespace Greenshot { this.linkLabel1.Size = new System.Drawing.Size(130, 23); this.linkLabel1.TabIndex = 13; this.linkLabel1.TabStop = true; - this.linkLabel1.Text = "http://getgreenshot.org"; + this.linkLabel1.Text = "http://getgreenshot.org/?version=" + EnvironmentInfo.GetGreenshotVersion(true); this.linkLabel1.TextAlign = System.Drawing.ContentAlignment.TopRight; this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked); // diff --git a/Greenshot/Forms/AboutForm.cs b/Greenshot/Forms/AboutForm.cs index 4d3b83021..b71d9207a 100644 --- a/Greenshot/Forms/AboutForm.cs +++ b/Greenshot/Forms/AboutForm.cs @@ -39,7 +39,7 @@ namespace Greenshot { /// /// The about form /// - public partial class AboutForm : AnimatingBaseForm { + public sealed partial class AboutForm : AnimatingBaseForm { private static readonly ILog LOG = LogManager.GetLogger(typeof(AboutForm)); private Bitmap _bitmap; private readonly ColorAnimator _backgroundAnimation; @@ -145,11 +145,11 @@ namespace Greenshot { // Only use double-buffering when we are NOT in a Terminal Server session DoubleBuffered = !IsTerminalServerSession; - // Use the self drawn image, first we create the background to be the backcolor (as we animate from this) + // Use the self drawn image, first we create the background to be the back-color (as we animate from this) _bitmap = ImageHelper.CreateEmpty(90, 90, PixelFormat.Format24bppRgb, BackColor, 96, 96); pictureBox1.Image = _bitmap; - lblTitle.Text = "Greenshot " + EnvironmentInfo.GreenshotVersion + (IniConfig.IsPortable ? " Portable" : "") + (" (" + OsInfo.Bits) + " bit)"; + lblTitle.Text = "Greenshot " + EnvironmentInfo.GetGreenshotVersion() + (IniConfig.IsPortable ? " Portable" : "") + (" (" + OsInfo.Bits) + " bit)"; // Number of frames the pixel animation takes int frames = FramesForMillis(2000); diff --git a/Greenshot/Helpers/EnvironmentInfo.cs b/Greenshot/Helpers/EnvironmentInfo.cs index e1a1c236e..59caf857e 100644 --- a/Greenshot/Helpers/EnvironmentInfo.cs +++ b/Greenshot/Helpers/EnvironmentInfo.cs @@ -56,38 +56,38 @@ namespace Greenshot.Helpers return Type.GetType("System.Reflection.ReflectionContext", false) != null; } - public static string GreenshotVersion + public static string GetGreenshotVersion(bool shortVersion = false) { - get + var executingAssembly = Assembly.GetExecutingAssembly(); + + // Use assembly version + string greenshotVersion = executingAssembly.GetName().Version.ToString(); + + // Use AssemblyFileVersion if available + var assemblyFileVersionAttribute = executingAssembly.GetCustomAttribute(); + if (!string.IsNullOrEmpty(assemblyFileVersionAttribute?.Version)) { - var executingAssembly = Assembly.GetExecutingAssembly(); - - // Use assembly version - string greenshotVersion = executingAssembly.GetName().Version.ToString(); - - // Use AssemblyFileVersion if available - var v = executingAssembly.GetName().Version; - var assemblyFileVersion = executingAssembly.GetCustomAttribute(); - if (!string.IsNullOrEmpty(assemblyFileVersion?.Version)) - { - greenshotVersion = assemblyFileVersion.Version; - } + var assemblyFileVersion = new Version(assemblyFileVersionAttribute.Version); + greenshotVersion = assemblyFileVersion.ToString(3); + } + if (!shortVersion) + { // Use AssemblyInformationalVersion if available - var assemblyInformationalVersion = executingAssembly.GetCustomAttribute(); - if (!string.IsNullOrEmpty(assemblyInformationalVersion?.InformationalVersion)) + var informationalVersionAttribute = executingAssembly.GetCustomAttribute(); + if (!string.IsNullOrEmpty(informationalVersionAttribute?.InformationalVersion)) { - greenshotVersion = assemblyInformationalVersion.InformationalVersion; + greenshotVersion = informationalVersionAttribute.InformationalVersion; } - - return greenshotVersion.Replace("+", " - "); } + + return greenshotVersion.Replace("+", " - "); } public static string EnvironmentToString(bool newline) { StringBuilder environment = new StringBuilder(); - environment.Append("Software version: " + GreenshotVersion); + environment.Append("Software version: " + GetGreenshotVersion()); if (IniConfig.IsPortable) { environment.Append(" Portable"); } diff --git a/version.json b/version.json index 10ccb44d4..1ff9dd100 100644 --- a/version.json +++ b/version.json @@ -10,14 +10,14 @@ }, "cloudBuild": { "setVersionVariables": true, - "setAllVariables": true, - "buildNumber": { - "enabled": true, - "includeCommitId": { - "when": "nonPublicReleaseOnly", - "where": "buildMetadata" + "setAllVariables": true, + "buildNumber": { + "enabled": true, + "includeCommitId": { + "when": "nonPublicReleaseOnly", + "where": "buildMetadata" + } } - } }, "inherit": false } \ No newline at end of file