From 6d77b1fc5f24a91c471ca76a09d4f16a8dbc23fb Mon Sep 17 00:00:00 2001 From: Sean Feldman Date: Thu, 4 May 2017 01:40:52 -0600 Subject: [PATCH] Revert "Merge pull request #108 from paolosalvatori/assembly-version-locally-and-on-buildserver" This reverts commit 666eb7bf65e4e71069aca3fcf2bbc0fd3e032fc8, reversing changes made to 957e3b964e71eb672513529cf2291147a64c0d0d. --- Forms/AboutForm.Designer.cs | 78 ++++++++----------- Forms/AboutForm.cs | 6 +- Forms/MainForm.cs | 11 ++- Helpers/VersionHelper.cs | 68 ++++++++++++++++ Properties/AssemblyInfo.cs | 2 + .../Properties/AssemblyInfo.cs | 36 +++++++++ .../ServiceBusExplorer.Tests.csproj | 4 +- ServiceBusExplorer.csproj | 1 + appveyor.yml | 2 +- 9 files changed, 152 insertions(+), 56 deletions(-) create mode 100644 Helpers/VersionHelper.cs create mode 100644 ServiceBusExplorer.Tests/Properties/AssemblyInfo.cs diff --git a/Forms/AboutForm.Designer.cs b/Forms/AboutForm.Designer.cs index 0e1e6722..723051b6 100644 --- a/Forms/AboutForm.Designer.cs +++ b/Forms/AboutForm.Designer.cs @@ -23,7 +23,7 @@ namespace Microsoft.Azure.ServiceBusExplorer.Forms { - sealed partial class AboutForm + partial class AboutForm { /// /// Required designer variable. @@ -56,7 +56,7 @@ private void InitializeComponent() System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AboutForm)); this.lblCorporation = new System.Windows.Forms.Label(); this.lblName = new System.Windows.Forms.Label(); - this.lblVersion = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.mailLinkLabel = new System.Windows.Forms.LinkLabel(); this.blogLinkLabel = new System.Windows.Forms.LinkLabel(); @@ -70,10 +70,9 @@ private void InitializeComponent() // this.lblCorporation.AutoSize = true; this.lblCorporation.BackColor = System.Drawing.Color.Transparent; - this.lblCorporation.Location = new System.Drawing.Point(13, 555); - this.lblCorporation.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lblCorporation.Location = new System.Drawing.Point(368, 360); this.lblCorporation.Name = "lblCorporation"; - this.lblCorporation.Size = new System.Drawing.Size(161, 20); + this.lblCorporation.Size = new System.Drawing.Size(107, 13); this.lblCorporation.TabIndex = 39; this.lblCorporation.Text = "Microsoft Corporation"; // @@ -82,34 +81,30 @@ private void InitializeComponent() this.lblName.AutoSize = true; this.lblName.BackColor = System.Drawing.Color.Transparent; this.lblName.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblName.Location = new System.Drawing.Point(13, 524); - this.lblName.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lblName.Location = new System.Drawing.Point(368, 340); this.lblName.Name = "lblName"; - this.lblName.Size = new System.Drawing.Size(182, 25); + this.lblName.Size = new System.Drawing.Size(117, 16); this.lblName.TabIndex = 37; this.lblName.Text = "Paolo Salvatori"; // - // lblVersion + // label3 // - this.lblVersion.AutoEllipsis = true; - this.lblVersion.AutoSize = true; - this.lblVersion.BackColor = System.Drawing.Color.Transparent; - this.lblVersion.Location = new System.Drawing.Point(13, 493); - this.lblVersion.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.lblVersion.Name = "lblVersion"; - this.lblVersion.Size = new System.Drawing.Size(71, 20); - this.lblVersion.TabIndex = 42; - this.lblVersion.Text = "Version: "; + this.label3.AutoSize = true; + this.label3.BackColor = System.Drawing.Color.Transparent; + this.label3.Location = new System.Drawing.Point(368, 320); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(72, 13); + this.label3.TabIndex = 42; + this.label3.Text = "Version: 1.0.0"; // // label2 // this.label2.AutoSize = true; this.label2.BackColor = System.Drawing.Color.Transparent; this.label2.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label2.Location = new System.Drawing.Point(13, 463); - this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label2.Location = new System.Drawing.Point(368, 300); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(244, 25); + this.label2.Size = new System.Drawing.Size(158, 16); this.label2.TabIndex = 41; this.label2.Text = "Service Bus Explorer"; // @@ -117,10 +112,9 @@ private void InitializeComponent() // this.mailLinkLabel.AutoSize = true; this.mailLinkLabel.BackColor = System.Drawing.Color.Transparent; - this.mailLinkLabel.Location = new System.Drawing.Point(97, 593); - this.mailLinkLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.mailLinkLabel.Location = new System.Drawing.Point(424, 385); this.mailLinkLabel.Name = "mailLinkLabel"; - this.mailLinkLabel.Size = new System.Drawing.Size(171, 20); + this.mailLinkLabel.Size = new System.Drawing.Size(114, 13); this.mailLinkLabel.TabIndex = 43; this.mailLinkLabel.TabStop = true; this.mailLinkLabel.Text = "paolos@microsoft.com"; @@ -130,10 +124,9 @@ private void InitializeComponent() // this.blogLinkLabel.AutoSize = true; this.blogLinkLabel.BackColor = System.Drawing.Color.Transparent; - this.blogLinkLabel.Location = new System.Drawing.Point(97, 618); - this.blogLinkLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.blogLinkLabel.Location = new System.Drawing.Point(424, 401); this.blogLinkLabel.Name = "blogLinkLabel"; - this.blogLinkLabel.Size = new System.Drawing.Size(215, 20); + this.blogLinkLabel.Size = new System.Drawing.Size(150, 13); this.blogLinkLabel.TabIndex = 44; this.blogLinkLabel.TabStop = true; this.blogLinkLabel.Text = "http://blogs.msdn.com/paolos"; @@ -143,10 +136,9 @@ private void InitializeComponent() // this.twitterLinkLabel.AutoSize = true; this.twitterLinkLabel.BackColor = System.Drawing.Color.Transparent; - this.twitterLinkLabel.Location = new System.Drawing.Point(97, 643); - this.twitterLinkLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.twitterLinkLabel.Location = new System.Drawing.Point(424, 417); this.twitterLinkLabel.Name = "twitterLinkLabel"; - this.twitterLinkLabel.Size = new System.Drawing.Size(208, 20); + this.twitterLinkLabel.Size = new System.Drawing.Size(145, 13); this.twitterLinkLabel.TabIndex = 45; this.twitterLinkLabel.TabStop = true; this.twitterLinkLabel.Text = "https://twitter.com/babosbird"; @@ -157,10 +149,9 @@ private void InitializeComponent() this.label1.AutoSize = true; this.label1.BackColor = System.Drawing.Color.Transparent; this.label1.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label1.Location = new System.Drawing.Point(13, 592); - this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label1.Location = new System.Drawing.Point(368, 384); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(69, 20); + this.label1.Size = new System.Drawing.Size(47, 13); this.label1.TabIndex = 46; this.label1.Text = "Email:"; // @@ -169,10 +160,9 @@ private void InitializeComponent() this.label4.AutoSize = true; this.label4.BackColor = System.Drawing.Color.Transparent; this.label4.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label4.Location = new System.Drawing.Point(13, 616); - this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label4.Location = new System.Drawing.Point(368, 400); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(59, 20); + this.label4.Size = new System.Drawing.Size(39, 13); this.label4.TabIndex = 47; this.label4.Text = "Blog:"; // @@ -181,27 +171,26 @@ private void InitializeComponent() this.label5.AutoSize = true; this.label5.BackColor = System.Drawing.Color.Transparent; this.label5.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label5.Location = new System.Drawing.Point(13, 641); - this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label5.Location = new System.Drawing.Point(368, 416); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(86, 20); + this.label5.Size = new System.Drawing.Size(57, 13); this.label5.TabIndex = 48; this.label5.Text = "Twitter:"; // // AboutForm // - this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(215)))), ((int)(((byte)(228)))), ((int)(((byte)(242))))); this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage"))); this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.ClientSize = new System.Drawing.Size(876, 678); + this.ClientSize = new System.Drawing.Size(584, 441); this.Controls.Add(this.label4); this.Controls.Add(this.label1); this.Controls.Add(this.twitterLinkLabel); this.Controls.Add(this.blogLinkLabel); this.Controls.Add(this.mailLinkLabel); - this.Controls.Add(this.lblVersion); + this.Controls.Add(this.label3); this.Controls.Add(this.label2); this.Controls.Add(this.lblCorporation); this.Controls.Add(this.lblName); @@ -210,12 +199,11 @@ private void InitializeComponent() this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.KeyPreview = true; - this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "AboutForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = " About Service Bus Explorer "; + this.Text = " About Service Bus Explorer 1.0.0"; this.Load += new System.EventHandler(this.AboutForm_Load); this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.AboutForm_KeyPress); this.ResumeLayout(false); @@ -227,7 +215,7 @@ private void InitializeComponent() private System.Windows.Forms.Label lblCorporation; private System.Windows.Forms.Label lblName; - private System.Windows.Forms.Label lblVersion; + private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label2; private System.Windows.Forms.LinkLabel mailLinkLabel; private System.Windows.Forms.LinkLabel blogLinkLabel; diff --git a/Forms/AboutForm.cs b/Forms/AboutForm.cs index 6c7331ce..0a9b347f 100644 --- a/Forms/AboutForm.cs +++ b/Forms/AboutForm.cs @@ -35,7 +35,7 @@ namespace Microsoft.Azure.ServiceBusExplorer.Forms { - public sealed partial class AboutForm : Form + public partial class AboutForm : Form { #region Private Fields private readonly Bitmap whiteLogoBitmap = new Bitmap(Resources.WhiteLogo); @@ -115,10 +115,6 @@ public AboutForm() timer.Interval = 40; timer.Tick += timer_Tick; timer.Enabled = true; - - var version = VersionProvider.GetVersion(); - Text += version; - lblVersion.Text += VersionProvider.GetVersionWithSha(); } #endregion diff --git a/Forms/MainForm.cs b/Forms/MainForm.cs index 9a720037..08ed279a 100644 --- a/Forms/MainForm.cs +++ b/Forms/MainForm.cs @@ -6911,8 +6911,15 @@ private async void purgeDeadletterQueueMessages_Click(object sender, EventArgs e private void MainForm_Load(object sender, EventArgs e) { - var version = VersionProvider.GetVersion(); - Text = $@"Service Bus Explore {version}"; + if (!Text.EndsWith("1.0.0")) + { + return; + } + var version = VersionHelper.RetrieveLatestReleaseFromGitHubAsync().Result; + if (!string.IsNullOrWhiteSpace(version)) + { + Text = $@"Service Bus Explore {version}"; + } } #endregion } diff --git a/Helpers/VersionHelper.cs b/Helpers/VersionHelper.cs new file mode 100644 index 00000000..a95a6a02 --- /dev/null +++ b/Helpers/VersionHelper.cs @@ -0,0 +1,68 @@ +#region Copyright +//======================================================================================= +// Microsoft Azure Customer Advisory Team +// +// This sample is supplemental to the technical guidance published on my personal +// blog at http://blogs.msdn.com/b/paolos/. +// +// Author: Paolo Salvatori +//======================================================================================= +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// LICENSED UNDER THE APACHE LICENSE, VERSION 2.0 (THE "LICENSE"); YOU MAY NOT USE THESE +// FILES EXCEPT IN COMPLIANCE WITH THE LICENSE. YOU MAY OBTAIN A COPY OF THE LICENSE AT +// http://www.apache.org/licenses/LICENSE-2.0 +// UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, SOFTWARE DISTRIBUTED UNDER THE +// LICENSE IS DISTRIBUTED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, EITHER EXPRESS OR IMPLIED. SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING +// PERMISSIONS AND LIMITATIONS UNDER THE LICENSE. +//======================================================================================= +#endregion + +#region Using Directives + +using System; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Threading.Tasks; +using Microsoft.Azure.ServiceBusExplorer.Forms; +using Newtonsoft.Json.Linq; + +#endregion + + +namespace Microsoft.Azure.ServiceBusExplorer.Helpers +{ + public static class VersionHelper + { + #region Public Static Methods + + public static async Task RetrieveLatestReleaseFromGitHubAsync() + { + try + { + var httpClient = new HttpClient + { + BaseAddress = new Uri("https://api.github.com") + }; + httpClient.DefaultRequestHeaders.Accept.Clear(); + httpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(new ProductHeaderValue("ServiceBusExplorer"))); + httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + + var httpResponseMessage = await httpClient.GetAsync("/repos/paolosalvatori/servicebusexplorer/releases/latest").ConfigureAwait(false); + if (httpResponseMessage.IsSuccessStatusCode) + { + var json = await httpResponseMessage.Content.ReadAsStringAsync(); + var jObject = JObject.Parse(json); + return (string)jObject.SelectToken("name"); + } + } + catch (Exception ex) + { + MainForm.SingletonMainForm.HandleException(ex); + } + return null; + } + #endregion + } +} diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index db57bb79..83561df7 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -12,6 +12,8 @@ [assembly: AssemblyCopyright("Copyright © Microsoft 2017")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from diff --git a/ServiceBusExplorer.Tests/Properties/AssemblyInfo.cs b/ServiceBusExplorer.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..a38b8763 --- /dev/null +++ b/ServiceBusExplorer.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ServiceBusExplorer.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("ServiceBusExplorer.Tests")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("ab80c6e1-376c-4e98-8512-5ac9161e932b")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj b/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj index 3a5adafd..b87abdc9 100644 --- a/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj +++ b/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj @@ -36,6 +36,7 @@ + @@ -50,9 +51,6 @@ - - -