diff --git a/TwinpackCli/Commands/UpdateCommand.cs b/TwinpackCli/Commands/UpdateCommand.cs index 4840147..087ccd0 100644 --- a/TwinpackCli/Commands/UpdateCommand.cs +++ b/TwinpackCli/Commands/UpdateCommand.cs @@ -67,53 +67,19 @@ public override int Execute(CommandContext context, Settings settings) Initialize(settings.Headed); - var usedPackages = _twinpack.RetrieveUsedPackagesAsync().GetAwaiter().GetResult(); - List packages; - if (settings.Packages != null || settings.Frameworks != null) - { - packages = usedPackages.Where( - x => (settings.ProjectName == null || settings.ProjectName == x.ProjectName) && - (settings.ProjectName == null || settings.ProjectName == x.ProjectName) && - (settings.Packages == null || settings.Packages.Any(y => y == x.Update?.Name)) && - (settings.Frameworks == null || settings.Frameworks.Any(y => y == x.Update?.Framework))) - .Select(x => new PackageItem(x) { Package = new Protocol.Api.PackageGetResponse(x.Update), PackageVersion = x.Update }).ToList(); - - foreach (var package in packages) - { - var i = settings.Packages != null && package.Package.Name != null ? Array.IndexOf(settings.Packages, package.Package.Name) : -1; - if (i >= 0) - { - package.Config.Version = settings.Versions?.ElementAtOrDefault(i) ?? package.PackageVersion.Version; - package.Config.Branch = settings.Branches?.ElementAtOrDefault(i) ?? package.PackageVersion.Branch; - package.Config.Configuration = settings.Configurations?.ElementAtOrDefault(i) ?? package.PackageVersion.Configuration; - package.Config.Target = settings.Targets?.ElementAtOrDefault(i) ?? package.PackageVersion.Target; - } - - i = settings.Frameworks != null && package.PackageVersion.Framework != null ? Array.IndexOf(settings.Frameworks, package.PackageVersion.Framework) : -1; - if (i >= 0) - { - package.Config.Version = settings.Versions?.ElementAtOrDefault(i) ?? package.PackageVersion.Version; - package.Config.Branch = settings.Branches?.ElementAtOrDefault(i) ?? package.PackageVersion.Branch; - package.Config.Configuration = settings.Configurations?.ElementAtOrDefault(i) ?? package.PackageVersion.Configuration; - package.Config.Target = settings.Targets?.ElementAtOrDefault(i) ?? package.PackageVersion.Target; - } - } - - // force new retrievable of metadata - foreach (var package in packages) - { - package.Package = null; - package.PackageVersion = null; - } - } - else - { - packages = usedPackages.Select(x => new PackageItem(x) { Package = new Protocol.Api.PackageGetResponse(x.Update), PackageVersion = x.Update }).ToList(); - } - // update all packages _twinpack.UpdatePackagesAsync( - packages, + new TwinpackService.UpdatePackageFilters + { + ProjectName = settings.ProjectName, + PlcName = settings.ProjectName, + Packages = settings.Packages, + Frameworks = settings.Frameworks, + Versions = settings.Versions, + Branches = settings.Branches, + Configurations = settings.Configurations, + Targets = settings.Targets, + }, new TwinpackService.UpdatePackageOptions { IncludeProvidedPackages = settings.IncludeProvidedPackages, diff --git a/TwinpackCore/Configuration/Config.cs b/TwinpackCore/Configuration/Config.cs index 9cd53ce..c5572a8 100644 --- a/TwinpackCore/Configuration/Config.cs +++ b/TwinpackCore/Configuration/Config.cs @@ -55,7 +55,6 @@ public ConfigPlcPackage(PackageItem pv) { Name = pv.PackageVersion?.Name ?? pv.Package?.Name ?? pv.Config?.Name ?? pv.Catalog?.Name; DistributorName = pv.PackageVersion?.DistributorName ?? pv.Package?.DistributorName ?? pv.Config?.DistributorName ?? pv.Catalog?.DistributorName; - Framework = pv.PackageVersion?.Framework ?? pv.Package?.Framework ?? pv.Config?.Framework; Version = pv.PackageVersion?.Version; Branch = pv.PackageVersion?.Branch; @@ -78,7 +77,6 @@ public ConfigPlcPackage(PackageVersionGetResponse pv) Namespace = pv.Name; Parameters = null; Options = null; - Framework = pv.Framework; } public ConfigPlcPackage(ConfigPlcPackage pv) @@ -92,12 +90,10 @@ public ConfigPlcPackage(ConfigPlcPackage pv) Namespace = pv.Name; Parameters = pv.Parameters; Options = pv.Options; - Framework = pv.Framework; } public ConfigPlcPackage() { - Repository = ""; Name = ""; Branch = "main"; Target = "TC3.1"; @@ -107,12 +103,10 @@ public ConfigPlcPackage() Namespace = null; Parameters = null; Options = null; - Framework = null; } [JsonPropertyName("version")] public string Version { get; set; } - [JsonPropertyName("repository")] - public string Repository { get; set; } + [JsonPropertyName("name")] public string Name { get; set; } @@ -151,10 +145,6 @@ public ConfigPlcPackage() [JsonPropertyName("options")] public AddPlcLibraryOptions Options { get; set; } - [DefaultValue(null)] - [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] - [JsonPropertyName("framework")] - public string Framework { get; set; } } // This class is used for deserializing a json config file diff --git a/TwinpackCore/Configuration/ConfigPlcFactory.cs b/TwinpackCore/Configuration/ConfigPlcFactory.cs index 5a0c683..984e0d8 100644 --- a/TwinpackCore/Configuration/ConfigPlcFactory.cs +++ b/TwinpackCore/Configuration/ConfigPlcFactory.cs @@ -193,7 +193,6 @@ AddPlcLibraryOptions ParseOptions(XElement element, bool isLibraryReference) packages.Add(new ConfigPlcPackage { DistributorName = packageVersion.DistributorName, - Repository = packageVersion.Repository, Branch = packageVersion.Branch, Configuration = packageVersion.Configuration, Name = packageVersion.Name, diff --git a/TwinpackCore/Core/TwinpackService.cs b/TwinpackCore/Core/TwinpackService.cs index 11f0589..f811a97 100644 --- a/TwinpackCore/Core/TwinpackService.cs +++ b/TwinpackCore/Core/TwinpackService.cs @@ -25,6 +25,7 @@ using Twinpack.Configuration; using System.Windows.Navigation; using Microsoft.VisualStudio.PlatformUI; +using NuGet.Configuration; namespace Twinpack.Core { diff --git a/TwinpackCore/Protocol/Native/TwinpackServer.cs b/TwinpackCore/Protocol/Native/TwinpackServer.cs index 963e699..aa61b22 100644 --- a/TwinpackCore/Protocol/Native/TwinpackServer.cs +++ b/TwinpackCore/Protocol/Native/TwinpackServer.cs @@ -655,7 +655,6 @@ public async Task PushAsync(IEnumerable plcs, string configura Binary = binary, Dependencies = plc.Packages?.Select(x => new PackageVersionDependency { - Repository = x.Repository, DistributorName = x.DistributorName, Name = x.Name, Version = x.Version, diff --git a/TwinpackTests/SystemTest.cs b/TwinpackTests/SystemTest.cs index d05913c..195aff7 100644 --- a/TwinpackTests/SystemTest.cs +++ b/TwinpackTests/SystemTest.cs @@ -12,6 +12,7 @@ namespace TwinpackTests using Microsoft.VisualStudio.PlatformUI; using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Collections.Generic; + using System.IO; using System.Linq; using System.Threading.Tasks; using System.Xml.Linq; diff --git a/TwinpackVsixShared/Dialogs/PackageVersionWindow.xaml.cs b/TwinpackVsixShared/Dialogs/PackageVersionWindow.xaml.cs index 9a8260f..f45a4fa 100644 --- a/TwinpackVsixShared/Dialogs/PackageVersionWindow.xaml.cs +++ b/TwinpackVsixShared/Dialogs/PackageVersionWindow.xaml.cs @@ -239,7 +239,6 @@ private async void Window_Loaded(object sender, RoutedEventArgs e) LatestVersion = _packageVersionLatest?.Version; Dependencies = _plcConfig?.Packages?.Select(x => new Protocol.Api.PackageVersionGetResponse { - Repository = x.Repository, DistributorName = x.DistributorName, Name = x.Name, Branch = x.Branch, @@ -919,7 +918,6 @@ private async void Publish_Click(object sender, RoutedEventArgs e) Binary = Convert.ToBase64String(File.ReadAllBytes($@"{cachePath}\{target}\{_plcConfig.Name}_{_plcConfig.Version}.{suffix}")), Dependencies = _plcConfig.Packages?.Select(x => new Protocol.Api.PackageVersionDependency { - Repository = x.Repository, DistributorName = x.DistributorName, Name = x.Name, Version = x.Version,