diff options
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/Publish')
3 files changed, 13 insertions, 131 deletions
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 1a289ff50..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,7 +10,6 @@ using System.Threading.Tasks; using Tango.AdvancedInstaller; using Tango.Core; using Tango.Core.Helpers; -using Tango.Git; using Tango.PMR.FirmwareUpgrade; using Tango.PPC.Common.Web; using Tango.SQLExaminer; @@ -60,11 +59,14 @@ namespace Tango.PPC.Common.Publish /// Gets the latest version. /// </summary> /// <returns></returns> - public async Task<LatestVersionResponse> GetRemoteVersion(String machineVersionGuid) + public async Task<String> GetRemoteVersion(String machineVersionGuid) { _client.Environment = Options.Environment; - var response = await _client.GetLatestVersion(new LatestVersionRequest() { MachineVersionGuid = machineVersionGuid }); - return response; + var response = await _client.GetLatestVersion(new LatestVersionRequest() + { + MachineVersionGuid = machineVersionGuid, + }); + return response.Version; } /// <summary> @@ -161,12 +163,8 @@ namespace Tango.PPC.Common.Publish OnPublishProgress(0, 100, $"Fetching remote version from {Options.Environment.ToAddress()}..."); - var r = GetRemoteVersion(Options.MachineVersionGuid).Result; - String remote_version = r.Version; - String remote_firmware_version = r.FirmwareVersion; - + String remote_version = GetRemoteVersion(Options.MachineVersionGuid).Result; String local_version = GetLocalVersion(); - String local_firmware_version = GetLocalFirmwareVersion(Options.TfpPath); OnPublishProgress(0, 100, $"Remote version: {remote_version}"); OnPublishProgress(0, 100, $"Local version: {local_version}"); @@ -176,11 +174,6 @@ namespace Tango.PPC.Common.Publish throw new InvalidOperationException($"The local version '{local_version}' is not greater than the remote version '{remote_version}'."); } - if (Version.Parse(local_firmware_version) < Version.Parse(remote_firmware_version)) - { - throw new InvalidOperationException($"The local firmware version '{local_firmware_version}' is not greater than the remote version '{remote_firmware_version}'."); - } - OnPublishProgress(0, 100, $"Requesting version upload..."); var response = _client.UploadVersion(new UploadVersionRequest() @@ -192,7 +185,6 @@ namespace Tango.PPC.Common.Publish FirmwareVersion = GetVersionInfoFromTFP(Options.TfpPath).FileDescriptors.SingleOrDefault(x => x.Destination == VersionFileDestination.Mcu).Version, }).Result; - CreateTupPackage(tempFile).Wait(); if (!String.IsNullOrWhiteSpace(Options.InstallerProject)) { @@ -218,6 +210,8 @@ namespace Tango.PPC.Common.Publish } } + CreateTupPackage(tempFile).Wait(); + OnPublishProgress(0, 100, $"Starting version upload..."); using (StorageBlobUploader uploader = new StorageBlobUploader(response.BlobAddress, tempFile)) @@ -240,7 +234,7 @@ namespace Tango.PPC.Common.Publish Token = response.Token, }).Wait(); - remote_version = GetRemoteVersion(Options.MachineVersionGuid).Result.Version; + remote_version = GetRemoteVersion(Options.MachineVersionGuid).Result; local_version = GetLocalVersion(); OnPublishProgress(0, 0, $"Remote version: {remote_version}"); @@ -251,55 +245,6 @@ namespace Tango.PPC.Common.Publish throw new InvalidOperationException("The remote version does not seems to have been updated."); } - if (Options.CreateTag) - { - String repoPath = Path.GetFullPath("../../../../../"); - String tagVersion = System.Version.Parse(GetLocalVersion()).ToString(3); - String tagName = $"PPC_v{tagVersion}"; - - using (GitRepositoryManager git = new GitRepositoryManager(repoPath, Options.Email, Options.PersonalAccessToken)) - { - OnPublishProgress(0, 100, "Checking repository changes..."); - int changes = git.GetChanges().Count; - if (changes > 0) - { - if (Options.AutoCommitAndPush) - { - OnPublishProgress(0, 100, "Committing repository changes..."); - git.Commit(tagName); - } - else - { - throw new InvalidOperationException($"There are {changes} uncommitted changes on the repository. Please commit and push all changes before creating the Tag"); - } - } - - OnPublishProgress(0, 100, "Checking outgoing commits..."); - int commits = git.GetOutgoingCommits().Count; - if (commits > 0) - { - if (Options.AutoCommitAndPush) - { - OnPublishProgress(0, 100, "Pushing repository changes..."); - git.Sync(); - } - else - { - throw new InvalidOperationException($"There are {commits} outgoing commits on the repository. Please push all commits before creating the Tag"); - } - } - - git.Progress += (x, e) => - { - OnPublishProgress(e.Progress.Value, e.Progress.Maximum, $"Pushing Tag '{tagName}'..."); - }; - - OnPublishProgress(0, 100, $"Creating Tag '{tagName}'..."); - - git.CreatePushTag(tagName, Options.Comments, "Roy Ben Shabat"); - } - } - OnPublishProgress(0, 0, "Version published successfully."); } catch (Exception ex) @@ -344,21 +289,13 @@ namespace Tango.PPC.Common.Publish using (ZipFile zip = new ZipFile()) { - zip.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression; - - if (Options.BuildConfig != "Debug") - { - zip.AddFile(Options.TfpPath, "/").FileName = "firmware_package.tfp"; - } + zip.AddFile(Options.TfpPath, "/").FileName = "firmware_package.tfp"; PublishInfo versionInfo = new PublishInfo(); versionInfo.ApplicationVersion = GetLocalVersion(); versionInfo.Comments = Options.Comments; versionInfo.Firmware = GetVersionInfoFromTFP(Options.TfpPath); - //Validate the package. - versionInfo.Firmware.Validate(); - var versionInfoFile = TemporaryManager.CreateImaginaryFile(); File.WriteAllText(versionInfoFile, versionInfo.ToJson()); zip.AddFile(versionInfoFile, "/").FileName = "version.json"; @@ -425,8 +362,6 @@ namespace Tango.PPC.Common.Publish var cuf = zip.AddFile(update_config_file, update_dir); cuf.FileName = update_dir + "\\config.xml"; - zip.AddDirectory(folder + "\\" + "Packages", "/Packages"); - foreach (var file in Directory.GetFiles(folder, "*.*", SearchOption.TopDirectoryOnly)) { zip.AddFile(file, "/"); @@ -469,16 +404,6 @@ namespace Tango.PPC.Common.Publish } /// <summary> - /// Gets the MCU version from the specified TFP file. - /// </summary> - /// <param name="tfpFile">The TFP file.</param> - /// <returns></returns> - public String GetLocalFirmwareVersion(String tfpFile) - { - return GetVersionInfoFromTFP(tfpFile).GetMcuVersion().ToString(); - } - - /// <summary> /// Raises the publish progress event. /// </summary> /// <param name="progress">The progress.</param> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PublishInfo.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PublishInfo.cs index 1bbdb80d0..77717254e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PublishInfo.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PublishInfo.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.PMR.FirmwareUpgrade; -using Tango.Web; namespace Tango.PPC.Common.Publish { @@ -14,9 +13,6 @@ namespace Tango.PPC.Common.Publish public String ApplicationVersion { get; set; } public VersionPackageDescriptor Firmware { get; set; } public String Comments { get; set; } - public bool IsMachineTupPackage { get; set; } - public String MachineSerialNumber { get; set; } - public DeploymentSlot MachineDeploymentSlot { get; set; } public PublishInfo() { @@ -28,25 +24,9 @@ namespace Tango.PPC.Common.Publish return JsonConvert.SerializeObject(this); } - public static PublishInfo FromJson(String json) + public PublishInfo FromJson(String json) { return JsonConvert.DeserializeObject<PublishInfo>(json); } - - public String GetFirmwareVersion() - { - Version version = new Version("1.0.0.0"); - - var s = Firmware.FileDescriptors.FirstOrDefault(x => x.Destination == VersionFileDestination.Mcu); - if (s != null) - { - if (Version.TryParse(s.Version,out version)) - { - return version.ToString(); - } - } - - return version.ToString(); - } } } 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 399a19f0d..4c40acb44 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PublishOptions.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PublishOptions.cs @@ -17,7 +17,6 @@ namespace Tango.PPC.Common.Publish public event EventHandler BuidConfigChanged; public event EventHandler BasicInfoChanged; public event EventHandler MachineVersionGuidChanged; - public event EventHandler TfpPathChanged; private String basePath; [Option("path", HelpText = "Specifies the application base path.", Required = false)] @@ -80,7 +79,7 @@ namespace Tango.PPC.Common.Publish public String TfpPath { get { return _tfpPath; } - set { _tfpPath = value; RaisePropertyChangedAuto(); TfpPathChanged?.Invoke(this, new EventArgs()); } + set { _tfpPath = value; RaisePropertyChangedAuto(); } } private String _installerProject; @@ -106,28 +105,6 @@ namespace Tango.PPC.Common.Publish set { _synchronization = value; RaisePropertyChangedAuto(); } } - private String _personalAccessToken; - public String PersonalAccessToken - { - get { return _personalAccessToken; } - set { _personalAccessToken = value; RaisePropertyChangedAuto(); } - } - - private bool _createTag; - public bool CreateTag - { - get { return _createTag; } - set { _createTag = value; RaisePropertyChangedAuto(); } - } - - private bool _autoCommitAndSync; - public bool AutoCommitAndPush - { - get { return _autoCommitAndSync; } - set { _autoCommitAndSync = value; RaisePropertyChangedAuto(); } - } - - public PublishOptions() { BasePath = AppDomain.CurrentDomain.BaseDirectory + "..\\"; |
