From 2f91af8a799782b821acf4e66c84ea7aefa27048 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 30 Oct 2019 16:31:07 +0200 Subject: Added firmware version to TANGO_VERSIONS. Added total version info to TUP file as 'version.json'. --- .../PPC/Tango.PPC.Common/Publish/PPCPublisher.cs | 25 +++++++++++++++++ .../PPC/Tango.PPC.Common/Publish/PublishInfo.cs | 32 ++++++++++++++++++++++ .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 11 ++++++-- .../Tango.PPC.Common/Web/UploadVersionRequest.cs | 2 ++ .../PPC/Tango.PPC.Common/packages.config | 1 + .../PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs | 2 +- 6 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PublishInfo.cs (limited to 'Software/Visual_Studio/PPC') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PPCPublisher.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PPCPublisher.cs index 5131522e0..526d4465a 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PPCPublisher.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PPCPublisher.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using Tango.AdvancedInstaller; using Tango.Core; using Tango.Core.Helpers; +using Tango.PMR.FirmwareUpgrade; using Tango.PPC.Common.Web; using Tango.SQLExaminer; using Tango.Transport.Web; @@ -181,6 +182,7 @@ namespace Tango.PPC.Common.Publish Version = local_version, MachineVersionGuid = Options.MachineVersionGuid, WithInstaller = !String.IsNullOrWhiteSpace(Options.InstallerProject), + FirmwareVersion = GetVersionInfoFromTFP(Options.TfpPath).FileDescriptors.SingleOrDefault(x => x.Destination == VersionFileDestination.Mcu).Version, }).Result; @@ -289,6 +291,15 @@ namespace Tango.PPC.Common.Publish { zip.AddFile(Options.TfpPath, "/").FileName = "firmware_package.tfp"; + PublishInfo versionInfo = new PublishInfo(); + versionInfo.ApplicationVersion = GetLocalVersion(); + versionInfo.Comments = Options.Comments; + versionInfo.Firmware = GetVersionInfoFromTFP(Options.TfpPath); + + var versionInfoFile = TemporaryManager.CreateImaginaryFile(); + File.WriteAllText(versionInfoFile, versionInfo.ToJson()); + zip.AddFile(versionInfoFile, "/").FileName = "version.json"; + String provision_dir = "Provision Scripts"; zip.AddDirectoryByName(provision_dir); @@ -378,6 +389,20 @@ namespace Tango.PPC.Common.Publish }); } + /// + /// Gets the version information from a TFP file. + /// + /// The TFP file. + /// + private VersionPackageDescriptor GetVersionInfoFromTFP(String tfpFile) + { + using (ZipFile zip = ZipFile.Read(tfpFile)) + { + var reader = zip.Entries.SingleOrDefault(x => x.FileName == "package.cfg").OpenReader(); + return VersionPackageDescriptor.Parser.ParseFrom(reader); + } + } + /// /// Raises the publish progress event. /// diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PublishInfo.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PublishInfo.cs new file mode 100644 index 000000000..77717254e --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PublishInfo.cs @@ -0,0 +1,32 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PMR.FirmwareUpgrade; + +namespace Tango.PPC.Common.Publish +{ + public class PublishInfo + { + public String ApplicationVersion { get; set; } + public VersionPackageDescriptor Firmware { get; set; } + public String Comments { get; set; } + + public PublishInfo() + { + Firmware = new VersionPackageDescriptor(); + } + + public String ToJson() + { + return JsonConvert.SerializeObject(this); + } + + public PublishInfo FromJson(String json) + { + return JsonConvert.DeserializeObject(json); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index 37885628d..21aad41f4 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -73,6 +73,9 @@ + + ..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll + @@ -117,6 +120,7 @@ GlobalVersionInfo.cs + @@ -144,6 +148,7 @@ + @@ -279,7 +284,9 @@ ResXFileCodeGenerator Resources.Designer.cs - + + Designer + SettingsSingleFileGenerator @@ -377,7 +384,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadVersionRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadVersionRequest.cs index 29d533043..eaf2c2002 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadVersionRequest.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadVersionRequest.cs @@ -12,6 +12,8 @@ namespace Tango.PPC.Common.Web { public String Version { get; set; } + public String FirmwareVersion { get; set; } + public String MachineVersionGuid { get; set; } public String Comments { get; set; } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/packages.config b/Software/Visual_Studio/PPC/Tango.PPC.Common/packages.config index d13fa64fc..50785f217 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/packages.config +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/packages.config @@ -6,6 +6,7 @@ + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs index 92deb6bca..02099e659 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs @@ -8,4 +8,4 @@ using System.Windows; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Tango PPC Application")] -[assembly: AssemblyVersion("1.0.49.0")] +[assembly: AssemblyVersion("1.0.50.0")] -- cgit v1.3.1