winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

ManifestInstaller.cs (10719B)


      1 // -----------------------------------------------------------------------------
      2 // <copyright file="ManifestInstaller.cs" company="Microsoft Corporation">
      3 //     Copyright (c) Microsoft Corporation. Licensed under the MIT License.
      4 // </copyright>
      5 // -----------------------------------------------------------------------------
      6 
      7 namespace Microsoft.WinGetUtil.Models.V1
      8 {
      9     using System.Collections.Generic;
     10     using YamlDotNet.Serialization;
     11 
     12     /// <summary>
     13     /// Class that contains the elements that represent what an installer element can contain in the manifest file.
     14     /// </summary>
     15     public class ManifestInstaller
     16     {
     17         /// <summary>
     18         /// Gets or sets the architecture of the installer. Values: x86, x64, arm, arm64, neutral.
     19         /// </summary>
     20         [YamlMember(Alias = "Architecture")]
     21         public string Arch { get; set; }
     22 
     23         /// <summary>
     24         /// Gets or sets the URL of the installer.
     25         /// </summary>
     26         [YamlMember(Alias = "InstallerUrl")]
     27         public string Url { get; set; }
     28 
     29         /// <summary>
     30         /// Gets or sets the SHA256 hash of the installer. Required element.
     31         /// </summary>
     32         [YamlMember(Alias = "InstallerSha256")]
     33         public string Sha256 { get; set; }
     34 
     35         /// <summary>
     36         /// Gets or sets the signature SHA256 for an appx/msix. Only used by appx/msix type.
     37         /// </summary>
     38         public string SignatureSha256 { get; set; }
     39 
     40         /// <summary>
     41         /// Gets or sets the Store ProductId. Only used when InstallerType is MSStore.
     42         /// </summary>
     43         [YamlMember(Alias = "MSStoreProductIdentifier")]
     44         public string ProductId { get; set; }
     45 
     46         // Common installer fields that may have defaults in manifest root level.
     47 
     48         /// <summary>
     49         /// Gets or sets the installer locale.
     50         /// </summary>
     51         public string InstallerLocale { get; set; }
     52 
     53         /// <summary>
     54         /// Gets or sets the list of supported platforms.
     55         /// </summary>
     56         public List<string> Platform { get; set; }
     57 
     58         /// <summary>
     59         /// Gets or sets the minimum OS version.
     60         /// </summary>
     61         public string MinimumOSVersion { get; set; }
     62 
     63         /// <summary>
     64         /// Gets or sets the installer type. If present, has more precedence than root.
     65         /// </summary>
     66         public string InstallerType { get; set; }
     67 
     68         /// <summary>
     69         /// Gets or sets the installer scope.
     70         /// </summary>
     71         public string Scope { get; set; }
     72 
     73         /// <summary>
     74         /// Gets or sets the list of install modes.
     75         /// </summary>
     76         public List<string> InstallModes { get; set; }
     77 
     78         /// <summary>
     79         /// Gets or sets the list of additional installer success codes.
     80         /// </summary>
     81         public List<long> InstallerSuccessCodes { get; set; }
     82 
     83         /// <summary>
     84         /// Gets or sets the upgrade behavior.
     85         /// </summary>
     86         public string UpgradeBehavior { get; set; }
     87 
     88         /// <summary>
     89         /// Gets or sets the list of commands.
     90         /// </summary>
     91         public List<string> Commands { get; set; }
     92 
     93         /// <summary>
     94         /// Gets or sets the list of supported protocols.
     95         /// </summary>
     96         public List<string> Protocols { get; set; }
     97 
     98         /// <summary>
     99         /// Gets or sets the list of supported file extensions.
    100         /// </summary>
    101         public List<string> FileExtensions { get; set; }
    102 
    103         /// <summary>
    104         /// Gets or sets the package family name for msix packaged installers.
    105         /// </summary>
    106         public string PackageFamilyName { get; set; }
    107 
    108         /// <summary>
    109         /// Gets or sets product code for ARP (Add/Remove Programs) installers.
    110         /// </summary>
    111         public string ProductCode { get; set; }
    112 
    113         /// <summary>
    114         /// Gets or sets the list of capabilities. For msix only.
    115         /// </summary>
    116         public List<string> Capabilities { get; set; }
    117 
    118         /// <summary>
    119         /// Gets or sets the list of restricted capabilities. For msix only.
    120         /// </summary>
    121         public List<string> RestrictedCapabilities { get; set; }
    122 
    123         /// <summary>
    124         /// Gets or sets the installer dependency.
    125         /// </summary>
    126         public InstallerDependency Dependencies { get; set; }
    127 
    128         /// <summary>
    129         /// Gets or sets the installer switches. If present, has more precedence than root.
    130         /// </summary>
    131         [YamlMember(Alias = "InstallerSwitches")]
    132         public InstallerSwitches Switches { get; set; }
    133 
    134         /// <summary>
    135         /// Gets or sets the installer markets info.
    136         /// </summary>
    137         public InstallerMarkets Markets { get; set; }
    138 
    139         /// <summary>
    140         /// Gets or sets a value indicating whether the installer behavior aborts terminal.
    141         /// </summary>
    142         public bool? InstallerAbortsTerminal { get; set; }
    143 
    144         /// <summary>
    145         /// Gets or sets a value indicating whether the installer behavior requires explicit install location.
    146         /// </summary>
    147         public bool? InstallLocationRequired { get; set; }
    148 
    149         /// <summary>
    150         /// Gets or sets a value indicating whether the installer behavior requires explicit upgrade.
    151         /// </summary>
    152         public bool? RequireExplicitUpgrade { get; set; }
    153 
    154         /// <summary>
    155         /// Gets or sets the installer release date.
    156         /// </summary>
    157         public string ReleaseDate { get; set; }
    158 
    159         /// <summary>
    160         /// Gets or sets the list of unsupported OS architectures.
    161         /// </summary>
    162         public List<string> UnsupportedOSArchitectures { get; set; }
    163 
    164         /// <summary>
    165         /// Gets or sets the list of apps and features entries.
    166         /// </summary>
    167         public List<InstallerArpEntry> AppsAndFeaturesEntries { get; set; }
    168 
    169         /// <summary>
    170         /// Gets or sets the installer elevation requirement.
    171         /// </summary>
    172         public string ElevationRequirement { get; set; }
    173 
    174         /// <summary>
    175         /// Gets or sets the list of installer expected return codes.
    176         /// </summary>
    177         public List<InstallerExpectedReturnCode> ExpectedReturnCodes { get; set; }
    178 
    179         /// <summary>
    180         /// Gets or sets the installation metadata.
    181         /// </summary>
    182         public InstallerInstallationMetadata InstallationMetadata { get; set; }
    183 
    184         /// <summary>
    185         /// Gets or sets the nested installer type.
    186         /// </summary>
    187         public string NestedInstallerType { get; set; }
    188 
    189         /// <summary>
    190         /// Gets or sets the nested installer files.
    191         /// </summary>
    192         public List<InstallerNestedInstallerFile> NestedInstallerFiles { get; set; }
    193 
    194         /// <summary>
    195         /// Gets or sets the unsupported arguments.
    196         /// </summary>
    197         public List<string> UnsupportedArguments { get; set; }
    198 
    199         /// <summary>
    200         /// Gets or sets a value indicating whether to display install warnings.
    201         /// </summary>
    202         public bool? DisplayInstallWarnings { get; set; }
    203 
    204         /// <summary>
    205         /// Gets or sets a value indicating whether the installer is prohibited from being downloaded for offline installation.
    206         /// </summary>
    207         public bool? DownloadCommandProhibited { get; set; }
    208 
    209         /// <summary>
    210         /// Gets or sets a value indicating whether the install location should be added directly to the PATH environment variable.
    211         /// </summary>
    212         public bool? ArchiveBinariesDependOnPath { get; set; }
    213 
    214         /// <summary>
    215         /// Gets or sets the repair behavior.
    216         /// </summary>
    217         public string RepairBehavior { get; set; }
    218 
    219         /// <summary>
    220         /// Gets or sets the installer authentication info.
    221         /// </summary>
    222         public InstallerAuthentication Authentication { get; set; }
    223 
    224         /// <summary>
    225         /// Returns a List of strings containing the URIs contained within this installer.
    226         /// </summary>
    227         /// <returns>List of strings.</returns>
    228         public List<string> GetURIs()
    229         {
    230             List<string> uris = new List<string>();
    231             if (!string.IsNullOrEmpty(this.Url))
    232             {
    233                 uris.Add(this.Url);
    234             }
    235 
    236             return uris;
    237         }
    238 
    239         /// <summary>
    240         /// Override object.Equals.
    241         /// </summary>
    242         /// <param name="other">other object.</param>
    243         /// <returns>boolean indicating if the objects are equals.</returns>
    244         public override bool Equals(object other)
    245         {
    246             return (other is ManifestInstaller) && this.Equals(other as ManifestInstaller);
    247         }
    248 
    249         /// <summary>
    250         /// Implemented IEquitable.
    251         /// </summary>
    252         /// <param name="other">other object.</param>
    253         /// <returns>boolean indicating if the objects are equals.</returns>
    254         public bool Equals(ManifestInstaller other)
    255         {
    256             // If parameter is null, return false.
    257             if (ReferenceEquals(other, null))
    258             {
    259                 return false;
    260             }
    261 
    262             // Optimization for a common success case.
    263             if (ReferenceEquals(this, other))
    264             {
    265                 return true;
    266             }
    267 
    268             // If run-time types are not exactly the same, return false.
    269             if (this.GetType() != other.GetType())
    270             {
    271                 return false;
    272             }
    273 
    274             return (this.Arch == other.Arch) &&
    275                    (this.Url == other.Url) &&
    276                    (this.Sha256 == other.Sha256) &&
    277                    (this.SignatureSha256 == other.SignatureSha256) &&
    278                    (this.InstallerLocale == other.InstallerLocale) &&
    279                    (this.Scope == other.Scope) &&
    280                    (this.InstallerType == other.InstallerType) &&
    281                    (this.Switches == other.Switches) &&
    282                    (this.NestedInstallerType == other.NestedInstallerType) &&
    283                    (this.NestedInstallerFiles == other.NestedInstallerFiles);
    284     }
    285 
    286         /// <summary>
    287         /// Override object.GetHashCode.
    288         /// </summary>
    289         /// <returns>resulting hash.</returns>
    290         public override int GetHashCode()
    291         {
    292             return (this.Arch,
    293                     this.Url,
    294                     this.Sha256,
    295                     this.SignatureSha256,
    296                     this.InstallerLocale,
    297                     this.Scope,
    298                     this.InstallerType,
    299                     this.Switches,
    300                     this.NestedInstallerType,
    301                     this.NestedInstallerFiles).GetHashCode();
    302         }
    303     }
    304 }