From f7fbabff40363f86a98108e2fcdea969890f44d5 Mon Sep 17 00:00:00 2001 From: Ryan Fu Date: Fri, 27 May 2022 15:08:28 -0700 Subject: [PATCH 1/3] add support for 1_2 schema --- src/WingetCreateCLI/Commands/NewCommand.cs | 2 +- src/WingetCreateCLI/Commands/UpdateCommand.cs | 2 +- .../Properties/Resources.Designer.cs | 75 ++++++++++++- src/WingetCreateCLI/Properties/Resources.resx | 27 ++++- src/WingetCreateCore/Common/PackageParser.cs | 25 ++--- .../Models/DefaultLocaleManifestModels.cs | 51 ++++++++- .../Models/InstallerManifestModels.cs | 70 +++++++----- .../Models/InstallerMetadata.cs | 6 +- .../Models/LocaleManifestModels.cs | 45 +++++++- .../Models/SingletonManifestModels.cs | 105 +++++++++++++----- .../Models/VersionManifestModels.cs | 4 +- src/WingetCreateCore/WingetCreateCore.csproj | 10 +- .../UnitTests/UpdateCommandTests.cs | 16 +-- 13 files changed, 339 insertions(+), 99 deletions(-) diff --git a/src/WingetCreateCLI/Commands/NewCommand.cs b/src/WingetCreateCLI/Commands/NewCommand.cs index ebd49db6..205ac951 100644 --- a/src/WingetCreateCLI/Commands/NewCommand.cs +++ b/src/WingetCreateCLI/Commands/NewCommand.cs @@ -273,7 +273,7 @@ private static void PromptOptionalProperties(T manifest) if (type.IsEnumerable()) { Type elementType = type.GetGenericArguments().SingleOrDefault(); - if (elementType.IsNonStringClassType() && !Prompt.Confirm(Resources.EditAgreements_Message)) + if (elementType.IsNonStringClassType() && !Prompt.Confirm(string.Format(Resources.EditObjectTypeField_Message, property.Name))) { continue; } diff --git a/src/WingetCreateCLI/Commands/UpdateCommand.cs b/src/WingetCreateCLI/Commands/UpdateCommand.cs index d7e9d189..2fe4facc 100644 --- a/src/WingetCreateCLI/Commands/UpdateCommand.cs +++ b/src/WingetCreateCLI/Commands/UpdateCommand.cs @@ -519,7 +519,7 @@ private List ParseInstallerUrlsForArchOverride(List i string installerUrl = installerUrlOverride[0]; string overrideArchString = installerUrlOverride[1]; - InstallerArchitecture? overrideArch = overrideArchString.ToEnumOrDefault(); + Architecture? overrideArch = overrideArchString.ToEnumOrDefault(); if (overrideArch.HasValue) { installerMetadata.InstallerUrl = installerUrl; diff --git a/src/WingetCreateCLI/Properties/Resources.Designer.cs b/src/WingetCreateCLI/Properties/Resources.Designer.cs index 4515bacf..524921c9 100644 --- a/src/WingetCreateCLI/Properties/Resources.Designer.cs +++ b/src/WingetCreateCLI/Properties/Resources.Designer.cs @@ -447,6 +447,15 @@ public static string DiscardUpdateAndStartOver_Message { } } + /// + /// Looks up a localized string similar to Indicates whether winget should display a warning message if the install or upgrade is known to interfere with running applications. + /// + public static string DisplayInstallWarnings_KeywordDescription { + get { + return ResourceManager.GetString("DisplayInstallWarnings_KeywordDescription", resourceCulture); + } + } + /// /// Looks up a localized string similar to The DisplayName registry value. /// @@ -492,6 +501,33 @@ public static string DisplayVersion_KeywordDescription { } } + /// + /// Looks up a localized string similar to List of documentation. + /// + public static string Documentations_KeywordDescription { + get { + return ResourceManager.GetString("Documentations_KeywordDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The label of the documentation for providing software guides such as manuals and troubleshooting URLs. + /// + public static string DocumentLabel_KeywordDescription { + get { + return ResourceManager.GetString("DocumentLabel_KeywordDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The documentation URL. + /// + public static string DocumentUrl_KeywordDescription { + get { + return ResourceManager.GetString("DocumentUrl_KeywordDescription", resourceCulture); + } + } + /// /// Looks up a localized string similar to DONE. /// @@ -547,20 +583,20 @@ public static string DownloadInstaller_Message { } /// - /// Looks up a localized string similar to Would you like to edit the Agreements field?. + /// Looks up a localized string similar to Would you like to edit your manifests?. /// - public static string EditAgreements_Message { + public static string EditManifests_Message { get { - return ResourceManager.GetString("EditAgreements_Message", resourceCulture); + return ResourceManager.GetString("EditManifests_Message", resourceCulture); } } /// - /// Looks up a localized string similar to Would you like to edit your manifests?. + /// Looks up a localized string similar to Would you like to edit the {0} field?. /// - public static string EditManifests_Message { + public static string EditObjectTypeField_Message { get { - return ResourceManager.GetString("EditManifests_Message", resourceCulture); + return ResourceManager.GetString("EditObjectTypeField_Message", resourceCulture); } } @@ -843,6 +879,15 @@ public static string InitiatingGitHubLogin_Message { } } + /// + /// Looks up a localized string similar to The notes displayed to the user upon completion of a package installation. + /// + public static string InstallationNotes_KeywordDescription { + get { + return ResourceManager.GetString("InstallationNotes_KeywordDescription", resourceCulture); + } + } + /// /// Looks up a localized string similar to Indicates whether the installer will abort terminal. Default is false. /// @@ -1644,6 +1689,15 @@ public static string PullRequestURI_Message { } } + /// + /// Looks up a localized string similar to The purchase url for acquiring entitlement for the package. + /// + public static string PurchaseUrl_KeywordDescription { + get { + return ResourceManager.GetString("PurchaseUrl_KeywordDescription", resourceCulture); + } + } + /// /// Looks up a localized string similar to GitHub api rate limit exceeded. To extend your rate limit, provide your GitHub token with the '-t' flag or store one using the 'token --store' command.. /// @@ -1779,6 +1833,15 @@ public static string ReturnResponse_KeywordDescription { } } + /// + /// Looks up a localized string similar to The return response url to provide additional guidance for expected return codes. + /// + public static string ReturnResponseUrl_KeywordDescription { + get { + return ResourceManager.GetString("ReturnResponseUrl_KeywordDescription", resourceCulture); + } + } + /// /// Looks up a localized string similar to SAVE AND EXIT. /// diff --git a/src/WingetCreateCLI/Properties/Resources.resx b/src/WingetCreateCLI/Properties/Resources.resx index 00b8aafb..dcfafa7e 100644 --- a/src/WingetCreateCLI/Properties/Resources.resx +++ b/src/WingetCreateCLI/Properties/Resources.resx @@ -862,9 +862,9 @@ The DisplayVersion registry value - - Would you like to edit the Agreements field? - `Agreements` refers to a specific field name that the user can edit. + + Would you like to edit the {0} field? + {0} - will be replaced with the name of the object type field Installer exit codes for common errors @@ -894,4 +894,25 @@ Failed to update fork because the default branch is ahead by {0} commit(s). {0} - represents the number of commits the default branch is ahead by + + Indicates whether winget should display a warning message if the install or upgrade is known to interfere with running applications + + + List of documentation + + + The label of the documentation for providing software guides such as manuals and troubleshooting URLs + + + The documentation URL + + + The notes displayed to the user upon completion of a package installation + + + The purchase url for acquiring entitlement for the package + + + The return response url to provide additional guidance for expected return codes + \ No newline at end of file diff --git a/src/WingetCreateCore/Common/PackageParser.cs b/src/WingetCreateCore/Common/PackageParser.cs index 37a21c0c..463fac09 100644 --- a/src/WingetCreateCore/Common/PackageParser.cs +++ b/src/WingetCreateCore/Common/PackageParser.cs @@ -11,7 +11,6 @@ namespace Microsoft.WingetCreateCore using System.IO; using System.Linq; using System.Net.Http; - using System.Runtime.InteropServices; using System.Security.Cryptography; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -298,7 +297,7 @@ public static bool ParsePackageAndUpdateInstallerNode(Installer installer, strin else { // For a single installer, detect the architecture. If no architecture is detected, default to architecture from existing manifest. - newInstaller.Architecture = GetArchFromUrl(url) ?? GetMachineType(path)?.ToString().ToEnumOrDefault() ?? installer.Architecture; + newInstaller.Architecture = GetArchFromUrl(url) ?? GetMachineType(path)?.ToString().ToEnumOrDefault() ?? installer.Architecture; } newInstaller.InstallerUrl = url; @@ -465,7 +464,7 @@ private static bool ParsePackageAndGenerateInstallerNodes(InstallerMetadata inst var baseInstaller = new Installer(); baseInstaller.InstallerUrl = url; baseInstaller.InstallerSha256 = GetFileHash(path); - baseInstaller.Architecture = GetMachineType(path)?.ToString().ToEnumOrDefault() ?? InstallerArchitecture.Neutral; + baseInstaller.Architecture = GetMachineType(path)?.ToString().ToEnumOrDefault() ?? Architecture.Neutral; bool parseMsixResult = false; @@ -500,28 +499,28 @@ private static bool ParsePackageAndGenerateInstallerNodes(InstallerMetadata inst /// /// Installer url string. /// Installer architecture enum. - private static InstallerArchitecture? GetArchFromUrl(string url) + private static Architecture? GetArchFromUrl(string url) { - List archMatches = new List(); + List archMatches = new List(); // Arm must only be checked if arm64 check fails, otherwise it'll match for arm64 too if (Regex.Match(url, "arm64|aarch64", RegexOptions.IgnoreCase).Success) { - archMatches.Add(InstallerArchitecture.Arm64); + archMatches.Add(Architecture.Arm64); } else if (Regex.Match(url, @"\barm\b", RegexOptions.IgnoreCase).Success) { - archMatches.Add(InstallerArchitecture.Arm); + archMatches.Add(Architecture.Arm); } if (Regex.Match(url, "x64|win64|_64|64-bit", RegexOptions.IgnoreCase).Success) { - archMatches.Add(InstallerArchitecture.X64); + archMatches.Add(Architecture.X64); } if (Regex.Match(url, "x86|win32|ia32|_86|32-bit", RegexOptions.IgnoreCase).Success) { - archMatches.Add(InstallerArchitecture.X86); + archMatches.Add(Architecture.X86); } return archMatches.Count == 1 ? archMatches.Single() : null; @@ -713,7 +712,7 @@ private static bool ParseMsi(string path, Installer baseInstaller, Manifests man archString.EqualsIC("Arm64") ? "Arm64" : archString.EqualsIC("Arm") ? "Arm" : archString; - baseInstaller.Architecture = archString.ToEnumOrDefault() ?? InstallerArchitecture.Neutral; + baseInstaller.Architecture = archString.ToEnumOrDefault() ?? Architecture.Neutral; if (baseInstaller.InstallerLocale == null) { @@ -793,7 +792,7 @@ private static string GetApplicationProperty(AppxMetadata appxMetadata, string p private static void SetInstallerPropertiesFromAppxMetadata(AppxMetadata appxMetadata, Installer installer, InstallerManifest installerManifest) { - installer.Architecture = appxMetadata.Architecture.ToEnumOrDefault() ?? InstallerArchitecture.Neutral; + installer.Architecture = appxMetadata.Architecture.ToEnumOrDefault() ?? Architecture.Neutral; installer.MinimumOSVersion = SetInstallerStringPropertyIfNeeded(installerManifest?.MinimumOSVersion, appxMetadata.MinOSVersion?.ToString()); installer.PackageFamilyName = SetInstallerStringPropertyIfNeeded(installerManifest?.PackageFamilyName, appxMetadata.PackageFamilyName); @@ -839,7 +838,7 @@ private static AppxMetadata GetAppxMetadataAndSetInstallerProperties(string path appxMetadatas.Add(new AppxMetadata(appxFile.GetStream())); } } - catch (COMException) + catch (System.Runtime.InteropServices.COMException) { // Check if package is an Msix var appxMetadata = new AppxMetadata(path); @@ -862,7 +861,7 @@ private static AppxMetadata GetAppxMetadataAndSetInstallerProperties(string path return appxMetadatas.First(); } - catch (COMException) + catch (System.Runtime.InteropServices.COMException) { // Binary wasn't an MSIX return null; diff --git a/src/WingetCreateCore/Models/DefaultLocaleManifestModels.cs b/src/WingetCreateCore/Models/DefaultLocaleManifestModels.cs index accf7871..cb98669b 100644 --- a/src/WingetCreateCore/Models/DefaultLocaleManifestModels.cs +++ b/src/WingetCreateCore/Models/DefaultLocaleManifestModels.cs @@ -35,9 +35,37 @@ public System.Collections.Generic.IDictionary AdditionalProperti get { return _additionalProperties; } set { _additionalProperties = value; } } + + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.4.3.0 (Newtonsoft.Json v11.0.0.0)")] + public partial class Documentation + { + /// The label of the documentation for providing software guides such as manuals and troubleshooting URLs. + [Newtonsoft.Json.JsonProperty("DocumentLabel", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [System.ComponentModel.DataAnnotations.StringLength(100, MinimumLength = 1)] + public string DocumentLabel { get; set; } + + /// The documentation URL. + [Newtonsoft.Json.JsonProperty("DocumentUrl", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [System.ComponentModel.DataAnnotations.StringLength(2048)] + [System.ComponentModel.DataAnnotations.RegularExpression(@"^([Hh][Tt][Tt][Pp][Ss]?)://.+$")] + public string DocumentUrl { get; set; } + + private System.Collections.Generic.IDictionary _additionalProperties = new System.Collections.Generic.Dictionary(); + + [Newtonsoft.Json.JsonExtensionData] + public System.Collections.Generic.IDictionary AdditionalProperties + { + get { return _additionalProperties; } + set { _additionalProperties = value; } + } + + } - /// A representation of a multiple-file manifest representing a default app metadata in the OWC. v1.1.0 + /// A representation of a multiple-file manifest representing a default app metadata in the OWC. v1.2.0 [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.4.3.0 (Newtonsoft.Json v11.0.0.0)")] public partial class DefaultLocaleManifest { @@ -162,6 +190,21 @@ public partial class DefaultLocaleManifest [System.ComponentModel.DataAnnotations.RegularExpression(@"^([Hh][Tt][Tt][Pp][Ss]?)://.+$")] public string ReleaseNotesUrl { get; set; } + /// The purchase url for acquiring entitlement for the package. + [Newtonsoft.Json.JsonProperty("PurchaseUrl", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [System.ComponentModel.DataAnnotations.StringLength(2048)] + [System.ComponentModel.DataAnnotations.RegularExpression(@"^([Hh][Tt][Tt][Pp][Ss]?)://.+$")] + public string PurchaseUrl { get; set; } + + /// The notes displayed to the user upon completion of a package installation. + [Newtonsoft.Json.JsonProperty("InstallationNotes", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [System.ComponentModel.DataAnnotations.StringLength(256, MinimumLength = 1)] + public string InstallationNotes { get; set; } + + [Newtonsoft.Json.JsonProperty("Documentations", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [System.ComponentModel.DataAnnotations.MaxLength(256)] + public System.Collections.Generic.List Documentations { get; set; } + /// The manifest type [Newtonsoft.Json.JsonProperty("ManifestType", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] @@ -171,7 +214,7 @@ public partial class DefaultLocaleManifest [Newtonsoft.Json.JsonProperty("ManifestVersion", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] [System.ComponentModel.DataAnnotations.RegularExpression(@"^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])(\.(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])){2}$")] - public string ManifestVersion { get; set; } = "1.1.0"; + public string ManifestVersion { get; set; } = "1.2.0"; private System.Collections.Generic.IDictionary _additionalProperties = new System.Collections.Generic.Dictionary(); @@ -181,5 +224,7 @@ public System.Collections.Generic.IDictionary AdditionalProperti get { return _additionalProperties; } set { _additionalProperties = value; } } + + } -} +} \ No newline at end of file diff --git a/src/WingetCreateCore/Models/InstallerManifestModels.cs b/src/WingetCreateCore/Models/InstallerManifestModels.cs index 2d8b3515..28a4e9a2 100644 --- a/src/WingetCreateCore/Models/InstallerManifestModels.cs +++ b/src/WingetCreateCore/Models/InstallerManifestModels.cs @@ -42,6 +42,30 @@ public enum InstallerType [System.Runtime.Serialization.EnumMember(Value = @"pwa")] Pwa = 9, + [System.Runtime.Serialization.EnumMember(Value = @"portable")] + Portable = 10, + + } + + /// The installer target architecture + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.4.3.0 (Newtonsoft.Json v11.0.0.0)")] + public enum Architecture + { + [System.Runtime.Serialization.EnumMember(Value = @"x86")] + X86 = 0, + + [System.Runtime.Serialization.EnumMember(Value = @"x64")] + X64 = 1, + + [System.Runtime.Serialization.EnumMember(Value = @"arm")] + Arm = 2, + + [System.Runtime.Serialization.EnumMember(Value = @"arm64")] + Arm64 = 3, + + [System.Runtime.Serialization.EnumMember(Value = @"neutral")] + Neutral = 4, + } /// Scope indicates if the installer is per user or per machine @@ -243,11 +267,10 @@ public partial class Installer [System.ComponentModel.DataAnnotations.RegularExpression(@"^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])(\.(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])){0,3}$")] public string MinimumOSVersion { get; set; } - /// The installer target architecture [Newtonsoft.Json.JsonProperty("Architecture", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public InstallerArchitecture Architecture { get; set; } + public Architecture Architecture { get; set; } [Newtonsoft.Json.JsonProperty("InstallerType", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] @@ -303,7 +326,7 @@ public partial class Installer public System.Collections.Generic.List Protocols { get; set; } [Newtonsoft.Json.JsonProperty("FileExtensions", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - [System.ComponentModel.DataAnnotations.MaxLength(256)] + [System.ComponentModel.DataAnnotations.MaxLength(512)] public System.Collections.Generic.List FileExtensions { get; set; } [Newtonsoft.Json.JsonProperty("Dependencies", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] @@ -342,6 +365,9 @@ public partial class Installer [Newtonsoft.Json.JsonProperty("RequireExplicitUpgrade", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public bool? RequireExplicitUpgrade { get; set; } + [Newtonsoft.Json.JsonProperty("DisplayInstallWarnings", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public bool? DisplayInstallWarnings { get; set; } + [Newtonsoft.Json.JsonProperty("UnsupportedOSArchitectures", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ItemConverterType = typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public System.Collections.Generic.List UnsupportedOSArchitectures { get; set; } @@ -365,7 +391,7 @@ public System.Collections.Generic.IDictionary AdditionalProperti } - /// A representation of a single-file manifest representing an app installers in the OWC. v1.1.0 + /// A representation of a single-file manifest representing an app installers in the OWC. v1.2.0 [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.4.3.0 (Newtonsoft.Json v11.0.0.0)")] public partial class InstallerManifest { @@ -434,7 +460,7 @@ public partial class InstallerManifest public System.Collections.Generic.List Protocols { get; set; } [Newtonsoft.Json.JsonProperty("FileExtensions", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - [System.ComponentModel.DataAnnotations.MaxLength(256)] + [System.ComponentModel.DataAnnotations.MaxLength(512)] public System.Collections.Generic.List FileExtensions { get; set; } [Newtonsoft.Json.JsonProperty("Dependencies", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] @@ -484,6 +510,9 @@ public partial class InstallerManifest [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public ElevationRequirement? ElevationRequirement { get; set; } + [Newtonsoft.Json.JsonProperty("DisplayInstallWarnings", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public bool? DisplayInstallWarnings { get; set; } + [Newtonsoft.Json.JsonProperty("Installers", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.Required] [System.ComponentModel.DataAnnotations.MinLength(1)] @@ -499,7 +528,7 @@ public partial class InstallerManifest [Newtonsoft.Json.JsonProperty("ManifestVersion", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] [System.ComponentModel.DataAnnotations.RegularExpression(@"^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])(\.(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])){2}$")] - public string ManifestVersion { get; set; } = "1.1.0"; + public string ManifestVersion { get; set; } = "1.2.0"; private System.Collections.Generic.IDictionary _additionalProperties = new System.Collections.Generic.Dictionary(); @@ -550,26 +579,6 @@ public enum Platform } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.4.3.0 (Newtonsoft.Json v11.0.0.0)")] - public enum InstallerArchitecture - { - [System.Runtime.Serialization.EnumMember(Value = @"x86")] - X86 = 0, - - [System.Runtime.Serialization.EnumMember(Value = @"x64")] - X64 = 1, - - [System.Runtime.Serialization.EnumMember(Value = @"arm")] - Arm = 2, - - [System.Runtime.Serialization.EnumMember(Value = @"arm64")] - Arm64 = 3, - - [System.Runtime.Serialization.EnumMember(Value = @"neutral")] - Neutral = 4, - - } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.4.3.0 (Newtonsoft.Json v11.0.0.0)")] public enum InstallModes { @@ -595,6 +604,12 @@ public partial class ExpectedReturnCode [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public ExpectedReturnCodeReturnResponse ReturnResponse { get; set; } + /// The return response url to provide additional guidance for expected return codes + [Newtonsoft.Json.JsonProperty("ReturnResponseUrl", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [System.ComponentModel.DataAnnotations.StringLength(2048)] + [System.ComponentModel.DataAnnotations.RegularExpression(@"^([Hh][Tt][Tt][Pp][Ss]?)://.+$")] + public string ReturnResponseUrl { get; set; } + private System.Collections.Generic.IDictionary _additionalProperties = new System.Collections.Generic.Dictionary(); [Newtonsoft.Json.JsonExtensionData] @@ -672,6 +687,9 @@ public enum ExpectedReturnCodeReturnResponse [System.Runtime.Serialization.EnumMember(Value = @"blockedByPolicy")] BlockedByPolicy = 14, + [System.Runtime.Serialization.EnumMember(Value = @"custom")] + Custom = 15, + } [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.4.3.0 (Newtonsoft.Json v11.0.0.0)")] diff --git a/src/WingetCreateCore/Models/InstallerMetadata.cs b/src/WingetCreateCore/Models/InstallerMetadata.cs index c6ae3cca..15533f75 100644 --- a/src/WingetCreateCore/Models/InstallerMetadata.cs +++ b/src/WingetCreateCore/Models/InstallerMetadata.cs @@ -29,16 +29,16 @@ public class InstallerMetadata /// /// Gets or sets the architecture detected from the URL string. /// - public InstallerArchitecture? UrlArchitecture { get; set; } + public Architecture? UrlArchitecture { get; set; } /// /// Gets or sets the architecture detected from the binary. /// - public InstallerArchitecture? BinaryArchitecture { get; set; } + public Architecture? BinaryArchitecture { get; set; } /// /// Gets or sets the architecture specified as an override. /// - public InstallerArchitecture? OverrideArchitecture { get; set; } + public Architecture? OverrideArchitecture { get; set; } } } diff --git a/src/WingetCreateCore/Models/LocaleManifestModels.cs b/src/WingetCreateCore/Models/LocaleManifestModels.cs index 7acc3e73..c0c4339d 100644 --- a/src/WingetCreateCore/Models/LocaleManifestModels.cs +++ b/src/WingetCreateCore/Models/LocaleManifestModels.cs @@ -39,7 +39,33 @@ public System.Collections.Generic.IDictionary AdditionalProperti } - /// A representation of a multiple-file manifest representing app metadata in other locale in the OWC. v1.1.0 + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.4.3.0 (Newtonsoft.Json v11.0.0.0)")] + public partial class Documentation + { + /// The label of the documentation for providing software guides such as manuals and troubleshooting URLs. + [Newtonsoft.Json.JsonProperty("DocumentLabel", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [System.ComponentModel.DataAnnotations.StringLength(100, MinimumLength = 1)] + public string DocumentLabel { get; set; } + + /// The documentation URL. + [Newtonsoft.Json.JsonProperty("DocumentUrl", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [System.ComponentModel.DataAnnotations.StringLength(2048)] + [System.ComponentModel.DataAnnotations.RegularExpression(@"^([Hh][Tt][Tt][Pp][Ss]?)://.+$")] + public string DocumentUrl { get; set; } + + private System.Collections.Generic.IDictionary _additionalProperties = new System.Collections.Generic.Dictionary(); + + [Newtonsoft.Json.JsonExtensionData] + public System.Collections.Generic.IDictionary AdditionalProperties + { + get { return _additionalProperties; } + set { _additionalProperties = value; } + } + + + } + + /// A representation of a multiple-file manifest representing app metadata in other locale in the OWC. v1.2.0 [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.4.3.0 (Newtonsoft.Json v11.0.0.0)")] public partial class LocaleManifest { @@ -155,6 +181,21 @@ public partial class LocaleManifest [System.ComponentModel.DataAnnotations.RegularExpression(@"^([Hh][Tt][Tt][Pp][Ss]?)://.+$")] public string ReleaseNotesUrl { get; set; } + /// The purchase url for acquiring entitlement for the package. + [Newtonsoft.Json.JsonProperty("PurchaseUrl", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [System.ComponentModel.DataAnnotations.StringLength(2048)] + [System.ComponentModel.DataAnnotations.RegularExpression(@"^([Hh][Tt][Tt][Pp][Ss]?)://.+$")] + public string PurchaseUrl { get; set; } + + /// The notes displayed to the user upon completion of a package installation. + [Newtonsoft.Json.JsonProperty("InstallationNotes", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [System.ComponentModel.DataAnnotations.StringLength(256, MinimumLength = 1)] + public string InstallationNotes { get; set; } + + [Newtonsoft.Json.JsonProperty("Documentations", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [System.ComponentModel.DataAnnotations.MaxLength(256)] + public System.Collections.Generic.List Documentations { get; set; } + /// The manifest type [Newtonsoft.Json.JsonProperty("ManifestType", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] @@ -164,7 +205,7 @@ public partial class LocaleManifest [Newtonsoft.Json.JsonProperty("ManifestVersion", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] [System.ComponentModel.DataAnnotations.RegularExpression(@"^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])(\.(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])){2}$")] - public string ManifestVersion { get; set; } = "1.1.0"; + public string ManifestVersion { get; set; } = "1.2.0"; private System.Collections.Generic.IDictionary _additionalProperties = new System.Collections.Generic.Dictionary(); diff --git a/src/WingetCreateCore/Models/SingletonManifestModels.cs b/src/WingetCreateCore/Models/SingletonManifestModels.cs index 435e81b9..1151954f 100644 --- a/src/WingetCreateCore/Models/SingletonManifestModels.cs +++ b/src/WingetCreateCore/Models/SingletonManifestModels.cs @@ -37,6 +37,32 @@ public System.Collections.Generic.IDictionary AdditionalProperti } + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.4.3.0 (Newtonsoft.Json v11.0.0.0)")] + public partial class Documentation + { + /// The label of the documentation for providing software guides such as manuals and troubleshooting URLs. + [Newtonsoft.Json.JsonProperty("DocumentLabel", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [System.ComponentModel.DataAnnotations.StringLength(100, MinimumLength = 1)] + public string DocumentLabel { get; set; } + + /// The documentation URL. + [Newtonsoft.Json.JsonProperty("DocumentUrl", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [System.ComponentModel.DataAnnotations.StringLength(2048)] + [System.ComponentModel.DataAnnotations.RegularExpression(@"^([Hh][Tt][Tt][Pp][Ss]?)://.+$")] + public string DocumentUrl { get; set; } + + private System.Collections.Generic.IDictionary _additionalProperties = new System.Collections.Generic.Dictionary(); + + [Newtonsoft.Json.JsonExtensionData] + public System.Collections.Generic.IDictionary AdditionalProperties + { + get { return _additionalProperties; } + set { _additionalProperties = value; } + } + + } /// Enumeration of supported installer types. InstallerType is required in either root level or individual Installer level @@ -73,6 +99,30 @@ public enum InstallerType [System.Runtime.Serialization.EnumMember(Value = @"pwa")] Pwa = 9, + [System.Runtime.Serialization.EnumMember(Value = @"portable")] + Portable = 10, + + } + + /// The installer target architecture + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.4.3.0 (Newtonsoft.Json v11.0.0.0)")] + public enum Architecture + { + [System.Runtime.Serialization.EnumMember(Value = @"x86")] + X86 = 0, + + [System.Runtime.Serialization.EnumMember(Value = @"x64")] + X64 = 1, + + [System.Runtime.Serialization.EnumMember(Value = @"arm")] + Arm = 2, + + [System.Runtime.Serialization.EnumMember(Value = @"arm64")] + Arm64 = 3, + + [System.Runtime.Serialization.EnumMember(Value = @"neutral")] + Neutral = 4, + } /// Scope indicates if the installer is per user or per machine @@ -274,11 +324,10 @@ public partial class Installer [System.ComponentModel.DataAnnotations.RegularExpression(@"^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])(\.(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])){0,3}$")] public string MinimumOSVersion { get; set; } - /// The installer target architecture [Newtonsoft.Json.JsonProperty("Architecture", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public InstallerArchitecture Architecture { get; set; } + public Architecture Architecture { get; set; } [Newtonsoft.Json.JsonProperty("InstallerType", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] @@ -334,7 +383,7 @@ public partial class Installer public System.Collections.Generic.List Protocols { get; set; } [Newtonsoft.Json.JsonProperty("FileExtensions", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - [System.ComponentModel.DataAnnotations.MaxLength(256)] + [System.ComponentModel.DataAnnotations.MaxLength(512)] public System.Collections.Generic.List FileExtensions { get; set; } [Newtonsoft.Json.JsonProperty("Dependencies", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] @@ -396,7 +445,7 @@ public System.Collections.Generic.IDictionary AdditionalProperti } - /// A representation of a single-file manifest representing an app in the OWC. v1.1.0 + /// A representation of a single-file manifest representing an app in the OWC. v1.2.0 [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.4.3.0 (Newtonsoft.Json v11.0.0.0)")] public partial class SingletonManifest { @@ -517,6 +566,21 @@ public partial class SingletonManifest [System.ComponentModel.DataAnnotations.RegularExpression(@"^([Hh][Tt][Tt][Pp][Ss]?)://.+$")] public string ReleaseNotesUrl { get; set; } + /// The purchase url for acquiring entitlement for the package. + [Newtonsoft.Json.JsonProperty("PurchaseUrl", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [System.ComponentModel.DataAnnotations.StringLength(2048)] + [System.ComponentModel.DataAnnotations.RegularExpression(@"^([Hh][Tt][Tt][Pp][Ss]?)://.+$")] + public string PurchaseUrl { get; set; } + + /// The notes displayed to the user upon completion of a package installation. + [Newtonsoft.Json.JsonProperty("InstallationNotes", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [System.ComponentModel.DataAnnotations.StringLength(256, MinimumLength = 1)] + public string InstallationNotes { get; set; } + + [Newtonsoft.Json.JsonProperty("Documentations", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [System.ComponentModel.DataAnnotations.MaxLength(256)] + public System.Collections.Generic.List Documentations { get; set; } + [Newtonsoft.Json.JsonProperty("Channel", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.StringLength(16, MinimumLength = 1)] public string Channel { get; set; } @@ -570,7 +634,7 @@ public partial class SingletonManifest public System.Collections.Generic.List Protocols { get; set; } [Newtonsoft.Json.JsonProperty("FileExtensions", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - [System.ComponentModel.DataAnnotations.MaxLength(256)] + [System.ComponentModel.DataAnnotations.MaxLength(512)] public System.Collections.Generic.List FileExtensions { get; set; } [Newtonsoft.Json.JsonProperty("Dependencies", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] @@ -635,7 +699,7 @@ public partial class SingletonManifest [Newtonsoft.Json.JsonProperty("ManifestVersion", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] [System.ComponentModel.DataAnnotations.RegularExpression(@"^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])(\.(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])){2}$")] - public string ManifestVersion { get; set; } = "1.1.0"; + public string ManifestVersion { get; set; } = "1.2.0"; private System.Collections.Generic.IDictionary _additionalProperties = new System.Collections.Generic.Dictionary(); @@ -686,26 +750,6 @@ public enum Platform } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.4.3.0 (Newtonsoft.Json v11.0.0.0)")] - public enum InstallerArchitecture - { - [System.Runtime.Serialization.EnumMember(Value = @"x86")] - X86 = 0, - - [System.Runtime.Serialization.EnumMember(Value = @"x64")] - X64 = 1, - - [System.Runtime.Serialization.EnumMember(Value = @"arm")] - Arm = 2, - - [System.Runtime.Serialization.EnumMember(Value = @"arm64")] - Arm64 = 3, - - [System.Runtime.Serialization.EnumMember(Value = @"neutral")] - Neutral = 4, - - } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.4.3.0 (Newtonsoft.Json v11.0.0.0)")] public enum InstallModes { @@ -731,6 +775,12 @@ public partial class ExpectedReturnCode [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public ExpectedReturnCodeReturnResponse ReturnResponse { get; set; } + /// The return response url to provide additional guidance for expected return codes + [Newtonsoft.Json.JsonProperty("ReturnResponseUrl", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [System.ComponentModel.DataAnnotations.StringLength(2048)] + [System.ComponentModel.DataAnnotations.RegularExpression(@"^([Hh][Tt][Tt][Pp][Ss]?)://.+$")] + public string ReturnResponseUrl { get; set; } + private System.Collections.Generic.IDictionary _additionalProperties = new System.Collections.Generic.Dictionary(); [Newtonsoft.Json.JsonExtensionData] @@ -808,6 +858,9 @@ public enum ExpectedReturnCodeReturnResponse [System.Runtime.Serialization.EnumMember(Value = @"blockedByPolicy")] BlockedByPolicy = 14, + [System.Runtime.Serialization.EnumMember(Value = @"custom")] + Custom = 15, + } [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.4.3.0 (Newtonsoft.Json v11.0.0.0)")] diff --git a/src/WingetCreateCore/Models/VersionManifestModels.cs b/src/WingetCreateCore/Models/VersionManifestModels.cs index d4c1a931..3cab4fbd 100644 --- a/src/WingetCreateCore/Models/VersionManifestModels.cs +++ b/src/WingetCreateCore/Models/VersionManifestModels.cs @@ -8,7 +8,7 @@ namespace Microsoft.WingetCreateCore.Models.Version { #pragma warning disable // Disable all warnings - /// A representation of a multi-file manifest representing an app version in the OWC. v1.1.0 + /// A representation of a multi-file manifest representing an app version in the OWC. v1.2.0 [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.4.3.0 (Newtonsoft.Json v11.0.0.0)")] public partial class VersionManifest { @@ -42,7 +42,7 @@ public partial class VersionManifest [Newtonsoft.Json.JsonProperty("ManifestVersion", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] [System.ComponentModel.DataAnnotations.RegularExpression(@"^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])(\.(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])){2}$")] - public string ManifestVersion { get; set; } = "1.1.0"; + public string ManifestVersion { get; set; } = "1.2.0"; private System.Collections.Generic.IDictionary _additionalProperties = new System.Collections.Generic.Dictionary(); diff --git a/src/WingetCreateCore/WingetCreateCore.csproj b/src/WingetCreateCore/WingetCreateCore.csproj index fbaac254..08ceb5e5 100644 --- a/src/WingetCreateCore/WingetCreateCore.csproj +++ b/src/WingetCreateCore/WingetCreateCore.csproj @@ -49,11 +49,11 @@ - - - - - + + + + + diff --git a/src/WingetCreateTests/WingetCreateTests/UnitTests/UpdateCommandTests.cs b/src/WingetCreateTests/WingetCreateTests/UnitTests/UpdateCommandTests.cs index 1df0c973..53fb8389 100644 --- a/src/WingetCreateTests/WingetCreateTests/UnitTests/UpdateCommandTests.cs +++ b/src/WingetCreateTests/WingetCreateTests/UnitTests/UpdateCommandTests.cs @@ -223,10 +223,10 @@ public async Task UpdateBasedOnInstallerUrlMatch() var archs = new[] { "arm64", "arm", "win64", "win32" }; var expectedArchs = new[] { - InstallerArchitecture.Arm64, - InstallerArchitecture.Arm, - InstallerArchitecture.X64, - InstallerArchitecture.X86, + Architecture.Arm64, + Architecture.Arm, + Architecture.X64, + Architecture.X86, }; TestUtils.InitializeMockDownloads(archs.Select(a => $"{a}/{TestConstants.TestMsiInstaller}").ToArray()); @@ -259,7 +259,7 @@ public async Task UpdateMsixIgnoresArchitectureFromUrl() Assert.IsNotNull(updatedManifests, "Command should have succeeded"); foreach (var updatedInstaller in updatedManifests.InstallerManifest.Installers) { - Assert.AreNotEqual(InstallerArchitecture.Arm64, updatedInstaller.Architecture, "Architecture should not be detected from string."); + Assert.AreNotEqual(Architecture.Arm64, updatedInstaller.Architecture, "Architecture should not be detected from string."); Assert.AreNotEqual(initialInstaller.InstallerSha256, updatedInstaller.InstallerSha256, "InstallerSha256 should be updated"); } } @@ -323,7 +323,7 @@ public async Task UpdateWithArchitectureOverrides() TestUtils.InitializeMockDownload(); TestUtils.SetMockHttpResponseContent(TestConstants.TestExeInstaller); string testInstallerUrl = $"https://fakedomain.com/{TestConstants.TestExeInstaller}"; - InstallerArchitecture expectedArch = InstallerArchitecture.Arm; + Architecture expectedArch = Architecture.Arm; // Test without architecture override should fail. (UpdateCommand badCommand, var manifests) = @@ -371,8 +371,8 @@ public async Task UpdateWithMultipleArchitectureOverrides() { var expectedArchs = new[] { - InstallerArchitecture.Arm, - InstallerArchitecture.X64, + Architecture.Arm, + Architecture.X64, }; string x64ExeInstallerUrl = $"https://fakedomain.com/{TestConstants.TestExeInstaller}"; From 0463c65a670bc29d69d1825d562526a9263c2148 Mon Sep 17 00:00:00 2001 From: Ryan Fu Date: Fri, 24 Jun 2022 10:12:32 -0700 Subject: [PATCH 2/3] update nuget package --- .../Properties/Resources.Designer.cs | 9 +++++++++ src/WingetCreateCLI/Properties/Resources.resx | 4 ++++ .../Models/InstallerManifestModels.cs | 17 +++++++++++++++++ .../Models/SingletonManifestModels.cs | 17 +++++++++++++++++ src/WingetCreateCore/WingetCreateCore.csproj | 4 ++-- 5 files changed, 49 insertions(+), 2 deletions(-) diff --git a/src/WingetCreateCLI/Properties/Resources.Designer.cs b/src/WingetCreateCLI/Properties/Resources.Designer.cs index 524921c9..facb9e64 100644 --- a/src/WingetCreateCLI/Properties/Resources.Designer.cs +++ b/src/WingetCreateCLI/Properties/Resources.Designer.cs @@ -2130,6 +2130,15 @@ public static string UnmatchedInstaller_Error { } } + /// + /// Looks up a localized string similar to List of winget arguments the installer does not support. + /// + public static string UnsupportedArguments_KeywordDescription { + get { + return ResourceManager.GetString("UnsupportedArguments_KeywordDescription", resourceCulture); + } + } + /// /// Looks up a localized string similar to List of OS architectures the installer does not support. /// diff --git a/src/WingetCreateCLI/Properties/Resources.resx b/src/WingetCreateCLI/Properties/Resources.resx index dcfafa7e..9543ca13 100644 --- a/src/WingetCreateCLI/Properties/Resources.resx +++ b/src/WingetCreateCLI/Properties/Resources.resx @@ -915,4 +915,8 @@ The return response url to provide additional guidance for expected return codes + + List of winget arguments the installer does not support + "winget" is the proper name of the tool + \ No newline at end of file diff --git a/src/WingetCreateCore/Models/InstallerManifestModels.cs b/src/WingetCreateCore/Models/InstallerManifestModels.cs index 28a4e9a2..aab77604 100644 --- a/src/WingetCreateCore/Models/InstallerManifestModels.cs +++ b/src/WingetCreateCore/Models/InstallerManifestModels.cs @@ -371,6 +371,9 @@ public partial class Installer [Newtonsoft.Json.JsonProperty("UnsupportedOSArchitectures", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ItemConverterType = typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public System.Collections.Generic.List UnsupportedOSArchitectures { get; set; } + [Newtonsoft.Json.JsonProperty("UnsupportedArguments", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ItemConverterType = typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public System.Collections.Generic.List UnsupportedArguments { get; set; } + [Newtonsoft.Json.JsonProperty("AppsAndFeaturesEntries", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.MaxLength(128)] public System.Collections.Generic.List AppsAndFeaturesEntries { get; set; } @@ -502,6 +505,9 @@ public partial class InstallerManifest [Newtonsoft.Json.JsonProperty("UnsupportedOSArchitectures", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ItemConverterType = typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public System.Collections.Generic.List UnsupportedOSArchitectures { get; set; } + [Newtonsoft.Json.JsonProperty("UnsupportedArguments", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ItemConverterType = typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public System.Collections.Generic.List UnsupportedArguments { get; set; } + [Newtonsoft.Json.JsonProperty("AppsAndFeaturesEntries", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.MaxLength(128)] public System.Collections.Generic.List AppsAndFeaturesEntries { get; set; } @@ -639,6 +645,17 @@ public enum UnsupportedOSArchitecture } + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.4.3.0 (Newtonsoft.Json v11.0.0.0)")] + public enum UnsupportedArgument + { + [System.Runtime.Serialization.EnumMember(Value = @"log")] + Log = 0, + + [System.Runtime.Serialization.EnumMember(Value = @"location")] + Location = 1, + + } + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.4.3.0 (Newtonsoft.Json v11.0.0.0)")] public enum ExpectedReturnCodeReturnResponse { diff --git a/src/WingetCreateCore/Models/SingletonManifestModels.cs b/src/WingetCreateCore/Models/SingletonManifestModels.cs index 1151954f..13e34e8f 100644 --- a/src/WingetCreateCore/Models/SingletonManifestModels.cs +++ b/src/WingetCreateCore/Models/SingletonManifestModels.cs @@ -425,6 +425,9 @@ public partial class Installer [Newtonsoft.Json.JsonProperty("UnsupportedOSArchitectures", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ItemConverterType = typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public System.Collections.Generic.List UnsupportedOSArchitectures { get; set; } + [Newtonsoft.Json.JsonProperty("UnsupportedArguments", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ItemConverterType = typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public System.Collections.Generic.List UnsupportedArguments { get; set; } + [Newtonsoft.Json.JsonProperty("AppsAndFeaturesEntries", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.MaxLength(128)] public System.Collections.Generic.List AppsAndFeaturesEntries { get; set; } @@ -676,6 +679,9 @@ public partial class SingletonManifest [Newtonsoft.Json.JsonProperty("UnsupportedOSArchitectures", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ItemConverterType = typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public System.Collections.Generic.List UnsupportedOSArchitectures { get; set; } + [Newtonsoft.Json.JsonProperty("UnsupportedArguments", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ItemConverterType = typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public System.Collections.Generic.List UnsupportedArguments { get; set; } + [Newtonsoft.Json.JsonProperty("AppsAndFeaturesEntries", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.MaxLength(128)] public System.Collections.Generic.List AppsAndFeaturesEntries { get; set; } @@ -810,6 +816,17 @@ public enum UnsupportedOSArchitecture } + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.4.3.0 (Newtonsoft.Json v11.0.0.0)")] + public enum UnsupportedArgument + { + [System.Runtime.Serialization.EnumMember(Value = @"log")] + Log = 0, + + [System.Runtime.Serialization.EnumMember(Value = @"location")] + Location = 1, + + } + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.4.3.0 (Newtonsoft.Json v11.0.0.0)")] public enum ExpectedReturnCodeReturnResponse { diff --git a/src/WingetCreateCore/WingetCreateCore.csproj b/src/WingetCreateCore/WingetCreateCore.csproj index 08ceb5e5..f1c0d1f3 100644 --- a/src/WingetCreateCore/WingetCreateCore.csproj +++ b/src/WingetCreateCore/WingetCreateCore.csproj @@ -19,7 +19,7 @@ - + @@ -52,8 +52,8 @@ - + From ebaab78ffc63aa5f92ddf03fe4aded93f57a3d6d Mon Sep 17 00:00:00 2001 From: Ryan Fu Date: Fri, 24 Jun 2022 12:30:10 -0700 Subject: [PATCH 3/3] add unit test --- src/WingetCreateCLI/Commands/UpdateCommand.cs | 1 + .../TestPublisher.FullSingleton1_2.yaml | 90 +++++++++++++++++++ .../UnitTests/UpdateCommandTests.cs | 13 +++ .../WingetCreateTests.csproj | 3 + 4 files changed, 107 insertions(+) create mode 100644 src/WingetCreateTests/WingetCreateTests/Resources/TestPublisher.FullSingleton1_2.yaml diff --git a/src/WingetCreateCLI/Commands/UpdateCommand.cs b/src/WingetCreateCLI/Commands/UpdateCommand.cs index 2fe4facc..234e2799 100644 --- a/src/WingetCreateCLI/Commands/UpdateCommand.cs +++ b/src/WingetCreateCLI/Commands/UpdateCommand.cs @@ -366,6 +366,7 @@ private static Manifests ConvertSingletonToMultifileManifest(WingetCreateCore.Mo cfg.CreateMap(); cfg.CreateMap(); // Markets2 is not used, but is required to satisfy mapping configuration. cfg.CreateMap(); + cfg.CreateMap(); }); var mapper = config.CreateMapper(); diff --git a/src/WingetCreateTests/WingetCreateTests/Resources/TestPublisher.FullSingleton1_2.yaml b/src/WingetCreateTests/WingetCreateTests/Resources/TestPublisher.FullSingleton1_2.yaml new file mode 100644 index 00000000..ae3c3cb6 --- /dev/null +++ b/src/WingetCreateTests/WingetCreateTests/Resources/TestPublisher.FullSingleton1_2.yaml @@ -0,0 +1,90 @@ +PackageIdentifier: TestPublisher.FullSingleton1_1 +PackageVersion: 0.1.2.3 +PackageLocale: en-US +DefaultLocale: en-US +Publisher: TestPublisher +PublisherUrl: https://fakeTestUrl.com +PublisherSupportUrl: https://fakeTestUrl.com +PrivacyUrl: https://fakeTestUrl.com +Author: fakeAuthor +PackageName: Full Singleton 1.1 Test +PackageUrl: https://fakeTestUrl.com +License: MIT +LicenseUrl: https://fakeTestUrl.com +Copyright: fakeCopyright +CopyrightUrl: https://fakeTestUrl.com +ShortDescription: A manifest used to verify that all fields from a full 1.1 singleton manifest can be deserialized and updated. +Description: A manifest used to verify that all fields from a full 1.1 singleton manifest can be deseri +Moniker: testMoniker +Tags: +- testSingleton +Agreements: +- AgreementLabel: fakeAgreementLabel + AgreementUrl: https://fakeTestUrl.com + Agreement: fakeAgreementContent +ReleaseNotes: fakeReleaseNotes +ReleaseNotesUrl: https://fakeTestUrl.com +PurchaseUrl: https://fakeTestUrl.com +InstallationNotes: fakeInstallationNotes +Documentations: +- DocumentLabel: fakeDocumentLabel +- DocumentUrl: fakeDocumentUrl +Installers: +- MinimumOSVersion: 10.0.0.0 + Architecture: x64 + InstallerUrl: https://fakedomain.com/WingetCreateTestExeInstaller.exe + InstallerType: exe + InstallerSha256: A7803233EEDB6A4B59B3024CCF9292A6FFFB94507DC998AA67C5B745D197A5DC + ProductCode: FakeProductCode + PackageFamilyName: FakePackageFamilyName + InstallModes: + - silent + InstallerSwitches: + Silent: /s + Upgrade: /u + InstallerSuccessCodes: + - 1 + ExpectedReturnCodes: + - InstallerReturnCode: 123 + ReturnResponse: alreadyInstalled + ReturnResponseUrl: https://fakeTestUrl.com + UpgradeBehavior: install + Commands: + - fakeCommand + Protocols: + - fakeProtocol + FileExtensions: + - .exe + Dependencies: + WindowsFeatures: + - fakeValue + WindowsLibraries: + - fakeValue + PackageDependencies: + - MinimumVersion: 10.0.0.0 + ExternalDependencies: + - fakeValue + Markets: + AllowedMarkets: + - fakeAllowedMarket + ExcludedMarkets: + - fakeExcludedMarket + InstallerAbortsTerminal: true + InstallLocationRequired: true + RequireExplicitUpgrade: true + UnsupportedOSArchitectures: + - arm64 + AppsAndFeaturesEntries: + - DisplayName: testName + Publisher: testPublisher + DisplayVersion: testVersion + UpgradeCode: fakeProductCode + ElevationRequirement: elevationRequired + ReleaseDate: 1-1-2022 + DisplayInstallWarnings: true + UnsupportedArguments: + - log + - location +ManifestType: singleton +ManifestVersion: 1.2.0 + diff --git a/src/WingetCreateTests/WingetCreateTests/UnitTests/UpdateCommandTests.cs b/src/WingetCreateTests/WingetCreateTests/UnitTests/UpdateCommandTests.cs index 53fb8389..fea41e0b 100644 --- a/src/WingetCreateTests/WingetCreateTests/UnitTests/UpdateCommandTests.cs +++ b/src/WingetCreateTests/WingetCreateTests/UnitTests/UpdateCommandTests.cs @@ -504,6 +504,19 @@ public async Task UpdateFullSingletonVersion1_1() Assert.IsNotNull(updatedManifests, "Command should have succeeded"); } + /// + /// Ensures that all fields from the Singleton v1.2. manifest can be deserialized and updated correctly. + /// + /// A representing the result of the asynchronous operation. + [Test] + public async Task UpdateFullSingletonVersion1_2() + { + TestUtils.InitializeMockDownloads(TestConstants.TestExeInstaller); + (UpdateCommand command, var initialManifestContent) = GetUpdateCommandAndManifestData("TestPublisher.FullSingleton1_2", null, this.tempPath, null); + var updatedManifests = await RunUpdateCommand(command, initialManifestContent); + Assert.IsNotNull(updatedManifests, "Command should have succeeded"); + } + /// /// Ensures that version specific fields are reset after an update. /// diff --git a/src/WingetCreateTests/WingetCreateTests/WingetCreateTests.csproj b/src/WingetCreateTests/WingetCreateTests/WingetCreateTests.csproj index 3a700fc9..53cbe8fa 100644 --- a/src/WingetCreateTests/WingetCreateTests/WingetCreateTests.csproj +++ b/src/WingetCreateTests/WingetCreateTests/WingetCreateTests.csproj @@ -33,6 +33,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest