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. --- .../Publish/MachineStudioPublisher.cs | 42 +++++++++++++++++++++- .../Publish/PublishOptions.cs | 8 +++++ .../Tango.MachineStudio.Common.csproj | 6 +++- .../Web/UploadVersionRequest.cs | 2 ++ .../Web/UploadVersionResponse.cs | 2 ++ .../MainWindow.xaml | 14 ++++++-- .../MainWindowVM.cs | 4 ++- .../PublisherSettings.cs | 20 +++++++++++ .../Tango.MachineStudio.Publisher.UI.csproj | 3 +- 9 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher.UI/PublisherSettings.cs (limited to 'Software/Visual_Studio/MachineStudio') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Publish/MachineStudioPublisher.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Publish/MachineStudioPublisher.cs index 3ee81f19b..fb5fbc27c 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Publish/MachineStudioPublisher.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Publish/MachineStudioPublisher.cs @@ -6,7 +6,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.Cryptography; using Tango.Core.Helpers; @@ -127,6 +129,19 @@ namespace Tango.MachineStudio.Common.Publish throw new FileNotFoundException($"Could not locate the machine studio 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}'."); + } + } + String tempFile = TemporaryManager.CreateFile(); return Task.Factory.StartNew(() => @@ -155,8 +170,33 @@ namespace Tango.MachineStudio.Common.Publish { Version = local_version, Comments = Options.Comments, + 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 = $"Machine Studio 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(); + } + } + OnPublishProgress(0, 100, $"Starting version packaging..."); using (ZipFile zip = new ZipFile()) @@ -188,7 +228,7 @@ namespace Tango.MachineStudio.Common.Publish { uploader.Progress += (x, e) => { - 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); }; uploader.Upload().Wait(); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Publish/PublishOptions.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Publish/PublishOptions.cs index 047d7c0b4..c5db355b1 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Publish/PublishOptions.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Publish/PublishOptions.cs @@ -73,6 +73,14 @@ namespace Tango.MachineStudio.Common.Publish 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(); } + } + public PublishOptions() { BasePath = AppDomain.CurrentDomain.BaseDirectory + "..\\"; diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj index 3f9133d43..5d9c48cd4 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj @@ -230,6 +230,10 @@ {bb2abb74-ba58-4812-83aa-ec8171f42df4} Tango.AutoComplete + + {c5df1816-34e5-4700-824c-29623a1baa22} + Tango.AdvancedInstaller + {f441feee-322a-4943-b566-110e12fd3b72} Tango.BL @@ -326,7 +330,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/UploadVersionRequest.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/UploadVersionRequest.cs index d27f48648..394658813 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/UploadVersionRequest.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/UploadVersionRequest.cs @@ -13,5 +13,7 @@ namespace Tango.MachineStudio.Common.Web public String Version { get; set; } public String Comments { get; set; } + + public bool WithInstaller { get; set; } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/UploadVersionResponse.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/UploadVersionResponse.cs index 9fb3ab94d..a5c5f8e56 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/UploadVersionResponse.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/UploadVersionResponse.cs @@ -13,5 +13,7 @@ namespace Tango.MachineStudio.Common.Web public String Token { get; set; } public String BlobAddress { get; set; } + + public String InstallerBlobAddress { get; set; } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher.UI/MainWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher.UI/MainWindow.xaml index b860994fd..0687ffed7 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher.UI/MainWindow.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher.UI/MainWindow.xaml @@ -7,7 +7,7 @@ xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:web="clr-namespace:Tango.Web;assembly=Tango.Web" mc:Ignorable="d" - Title="Machine Studio Publisher" Height="482" Width="700" WindowStartupLocation="CenterScreen" WindowStyle="ToolWindow" ResizeMode="NoResize" Foreground="#202020" d:DataContext="{d:DesignInstance Type=local:MainWindowVM, IsDesignTimeCreatable=False}"> + Title="Machine Studio Publisher" Height="520" Width="700" WindowStartupLocation="CenterScreen" WindowStyle="ToolWindow" ResizeMode="NoResize" Foreground="#202020" d:DataContext="{d:DesignInstance Type=local:MainWindowVM, IsDesignTimeCreatable=False}"> @@ -67,8 +67,18 @@ + + Installer Project: + + + + + Installer Output Folder: + + + Comments - + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher.UI/MainWindowVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher.UI/MainWindowVM.cs index e227c0904..479a657d6 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher.UI/MainWindowVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher.UI/MainWindowVM.cs @@ -63,7 +63,7 @@ namespace Tango.MachineStudio.Publisher.UI { PublishCommand = new RelayCommand(Publish, () => Options.Email != null && Options.Password != null && Options.Comments != null && LocalVersion != null && RemoteVersion != null && IsFree); - Options = new PublishOptions(); + Options = SettingsManager.Default.GetOrCreate().Options; _publisher = new MachineStudioPublisher(Options); _publisher.PublishProgress += _publisher_PublishProgress; @@ -93,6 +93,8 @@ namespace Tango.MachineStudio.Publisher.UI private async void Publish() { + SettingsManager.Default.Save(); + if (!ShowQuestion("Did you remember to synchronize production database ?")) { return; diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher.UI/PublisherSettings.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher.UI/PublisherSettings.cs new file mode 100644 index 000000000..dda722765 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher.UI/PublisherSettings.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.MachineStudio.Common.Publish; +using Tango.Settings; + +namespace Tango.MachineStudio.Publisher.UI +{ + public class PublisherSettings : SettingsBase + { + public PublishOptions Options { get; set; } + + public PublisherSettings() + { + Options = new PublishOptions(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher.UI/Tango.MachineStudio.Publisher.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher.UI/Tango.MachineStudio.Publisher.UI.csproj index f7b753e02..edcdfb567 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher.UI/Tango.MachineStudio.Publisher.UI.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher.UI/Tango.MachineStudio.Publisher.UI.csproj @@ -82,6 +82,7 @@ MSBuild:Compile Designer + MSBuild:Compile Designer @@ -174,7 +175,7 @@ - + \ No newline at end of file -- cgit v1.3.1