From 50b503a3b52692bb9debdee42150cd2bffcf581f Mon Sep 17 00:00:00 2001 From: Jeremy Tellier - ROG Date: Thu, 11 Jun 2020 20:32:36 +0100 Subject: [PATCH 1/2] Configure location of versioning --- ZitiUpdateService/App.config | 10 +++++++--- ZitiUpdateService/UpdateService.cs | 7 ++++++- ZitiUpdateService/ZitiUpdateService.csproj | 1 + 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ZitiUpdateService/App.config b/ZitiUpdateService/App.config index 193aecc6..18ca8d20 100644 --- a/ZitiUpdateService/App.config +++ b/ZitiUpdateService/App.config @@ -1,6 +1,10 @@  - - - + + + + + + + \ No newline at end of file diff --git a/ZitiUpdateService/UpdateService.cs b/ZitiUpdateService/UpdateService.cs index fa622d09..73746d05 100644 --- a/ZitiUpdateService/UpdateService.cs +++ b/ZitiUpdateService/UpdateService.cs @@ -13,6 +13,8 @@ using System.Net; using System.Timers; using System.Management.Automation; using System.Xml; +using System.Configuration; +using System.Collections.Specialized; namespace ZitiUpdateService { public partial class UpdateService : ServiceBase { @@ -27,6 +29,7 @@ namespace ZitiUpdateService { private string _rootDirectory = ""; private string _logDirectory = ""; private bool _isJustStopped = true; + private string _versionType = "release"; ServiceController controller; public UpdateService() { @@ -34,6 +37,8 @@ namespace ZitiUpdateService { } protected override void OnStart(string[] args) { + if (ConfigurationManager.AppSettings.Get("UpdateUrl")!=null) _versionUrl = ConfigurationManager.AppSettings.Get("UpdateUrl"); + if (ConfigurationManager.AppSettings.Get("Version") !=null) _versionType = ConfigurationManager.AppSettings.Get("Version"); _rootDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "NetFoundry"); if (!Directory.Exists(_rootDirectory)) Directory.CreateDirectory(_rootDirectory); _logDirectory = Path.Combine(_rootDirectory, "Logs"); @@ -90,7 +95,7 @@ namespace ZitiUpdateService { var result = readStream.ReadToEnd(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(result); - XmlNode node = xmlDoc.SelectSingleNode("metadata/versioning/release"); + XmlNode node = xmlDoc.SelectSingleNode("metadata/versioning/"+ _versionType); string version = node.InnerText; Log("Version Checked: " + version+" on "+_version); if (version != _version) { diff --git a/ZitiUpdateService/ZitiUpdateService.csproj b/ZitiUpdateService/ZitiUpdateService.csproj index 2bc88441..6b0fedfc 100644 --- a/ZitiUpdateService/ZitiUpdateService.csproj +++ b/ZitiUpdateService/ZitiUpdateService.csproj @@ -75,6 +75,7 @@ + From 1b7859ad500257e40d8091d85ee2be5d00045382 Mon Sep 17 00:00:00 2001 From: Jeremy Tellier - ROG Date: Thu, 11 Jun 2020 22:13:24 +0100 Subject: [PATCH 2/2] Proper Build Config for app.config file --- ZitiUpdateService/App.config | 2 +- ZitiUpdateService/UpdateService.cs | 2 +- ZitiUpdateService/ZitiUpdateService.csproj | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ZitiUpdateService/App.config b/ZitiUpdateService/App.config index 18ca8d20..bc30bb6b 100644 --- a/ZitiUpdateService/App.config +++ b/ZitiUpdateService/App.config @@ -2,7 +2,7 @@ - + diff --git a/ZitiUpdateService/UpdateService.cs b/ZitiUpdateService/UpdateService.cs index 73746d05..f8a9262f 100644 --- a/ZitiUpdateService/UpdateService.cs +++ b/ZitiUpdateService/UpdateService.cs @@ -21,7 +21,7 @@ namespace ZitiUpdateService { private string _version = ""; private bool _isNew = true; - private int _majorVersion = 1; + /// private int _majorVersion = 1; private string _versionUrl = "https://netfoundry.jfrog.io/netfoundry/ziti-maven-snapshot/ziti-tunnel-win/amd64/windows/ziti-tunnel-win/maven-metadata.xml"; private string _serviceUrl = "https://netfoundry.jfrog.io/netfoundry/ziti-maven-snapshot/ziti-tunnel-win/amd64/windows/ziti-tunnel-win/${version}/ziti-tunnel-win-${version}.zip"; private System.Timers.Timer _checkTimer = new System.Timers.Timer(); diff --git a/ZitiUpdateService/ZitiUpdateService.csproj b/ZitiUpdateService/ZitiUpdateService.csproj index 6b0fedfc..896f9f87 100644 --- a/ZitiUpdateService/ZitiUpdateService.csproj +++ b/ZitiUpdateService/ZitiUpdateService.csproj @@ -109,7 +109,9 @@ - + + Always +