From e112866a2cf44ddeb5b40e8ffc84614ecfe6abdf Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 25 Feb 2019 18:18:35 +0200 Subject: Implemented auto installer release for machine studio and PPC. --- .../PPC/Tango.PPC.Common/Publish/PPCPublisher.cs | 43 +++++++++++++++++++++- .../PPC/Tango.PPC.Common/Publish/PublishOptions.cs | 24 ++++++++---- .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 6 ++- .../Tango.PPC.Common/Web/UploadVersionRequest.cs | 2 + .../Tango.PPC.Common/Web/UploadVersionResponse.cs | 2 + 5 files changed, 67 insertions(+), 10 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common') 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 65709d46f..7c6113829 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PPCPublisher.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PPCPublisher.cs @@ -5,7 +5,9 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; +using Tango.AdvancedInstaller; using Tango.Core; using Tango.Core.Helpers; using Tango.PPC.Common.Web; @@ -136,6 +138,19 @@ namespace Tango.PPC.Common.Publish throw new FileNotFoundException($"Could not locate the PPC executable at {appPath}."); } + if (!String.IsNullOrWhiteSpace(Options.InstallerProject)) + { + if (!File.Exists(Options.InstallerProject)) + { + throw new FileNotFoundException($"Installer project not found at '{Options.InstallerProject}'."); + } + + if (!Directory.Exists(Options.InstallerOutputFolder)) + { + throw new DirectoryNotFoundException($"Installer output folder does not exists '{Options.InstallerOutputFolder}'."); + } + } + return Task.Factory.StartNew(() => { String tempFile = TemporaryManager.CreateFile(".zip"); @@ -165,8 +180,34 @@ namespace Tango.PPC.Common.Publish Comments = Options.Comments, Version = local_version, MachineVersionGuid = Options.MachineVersionGuid, + WithInstaller = !String.IsNullOrWhiteSpace(Options.InstallerProject), }).Result; + + if (!String.IsNullOrWhiteSpace(Options.InstallerProject)) + { + String output_folder = Options.InstallerOutputFolder; + OnPublishProgress(0, 100, $"Building installer project..."); + InstallerBuilder installerBuilder = new InstallerBuilder(Options.InstallerProject); + String installer_name = $"PPC Installer_v{Version.Parse(local_version).ToString(3)}.exe"; + String output_file = Path.Combine(output_folder, installer_name); + installerBuilder.Build(local_version, output_file).Wait(); + + Thread.Sleep(5000); + + OnPublishProgress(0, 100, $"Uploading installer '{installer_name}'..."); + + using (StorageBlobUploader uploader = new StorageBlobUploader(response.InstallerBlobAddress, output_file)) + { + uploader.Progress += (x, e) => + { + OnPublishProgress(e.Current, e.Total, $"Uploading installer {(((double)e.Current / (double)e.Total) * 100d).ToString("0.0")}%...", true); + }; + + uploader.Upload().Wait(); + } + } + CreateTupPackage(tempFile).Wait(); OnPublishProgress(0, 100, $"Starting version upload..."); @@ -177,7 +218,7 @@ namespace Tango.PPC.Common.Publish { InvokeUINow(() => { - OnPublishProgress(e.Current, e.Total, $"Uploading to storage {(((double)e.Current / (double)e.Total) * 100d).ToString("0.0")}%...", true); + OnPublishProgress(e.Current, e.Total, $"Uploading version {(((double)e.Current / (double)e.Total) * 100d).ToString("0.0")}%...", true); }); }; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PublishOptions.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PublishOptions.cs index fa04d8331..4c40acb44 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PublishOptions.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PublishOptions.cs @@ -66,14 +66,6 @@ namespace Tango.PPC.Common.Publish set { _environment = value; RaisePropertyChangedAuto(); EnvironmentChanged?.Invoke(this, new EventArgs()); } } - private String _installerProject; - [Option("installer-project-file", HelpText = "Specifies the advanced installer project file to build and upload.", Required = false)] - public String InstallerProject - { - get { return _installerProject; } - set { _installerProject = value; RaisePropertyChangedAuto(); } - } - private String _machineVersionGuid; [Option("machine-version-guid", HelpText = "Specifies the machine version id for which to upload the PPC version.", Required = true)] public String MachineVersionGuid @@ -90,6 +82,22 @@ namespace Tango.PPC.Common.Publish set { _tfpPath = value; RaisePropertyChangedAuto(); } } + private String _installerProject; + [Option("installer-project-file", HelpText = "Specifies the advanced installer project file to build and upload.", Required = false)] + public String InstallerProject + { + get { return _installerProject; } + set { _installerProject = value; RaisePropertyChangedAuto(); } + } + + private String _installerOutputFolder; + [Option("installer-output-folder", HelpText = "Specifies where to save the installer application.", Required = false)] + public String InstallerOutputFolder + { + get { return _installerOutputFolder; } + set { _installerOutputFolder = value; RaisePropertyChangedAuto(); } + } + private SynchronizationOptions _synchronization; public SynchronizationOptions Synchronization { 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 fe2f87fb2..07ea6c5d1 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 @@ -285,6 +285,10 @@ + + {c5df1816-34e5-4700-824c-29623a1baa22} + Tango.AdvancedInstaller + {f441feee-322a-4943-b566-110e12fd3b72} Tango.BL @@ -367,7 +371,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 d75a94300..29d533043 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadVersionRequest.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadVersionRequest.cs @@ -15,5 +15,7 @@ namespace Tango.PPC.Common.Web public String MachineVersionGuid { get; set; } public String Comments { get; set; } + + public bool WithInstaller { get; set; } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadVersionResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadVersionResponse.cs index 9a0fc1a5f..0b4859915 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadVersionResponse.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadVersionResponse.cs @@ -13,5 +13,7 @@ namespace Tango.PPC.Common.Web public String Token { get; set; } public String BlobAddress { get; set; } + + public String InstallerBlobAddress { get; set; } } } -- cgit v1.3.1