UpdatePackageCmdlet.cs (2430B)
1 // ----------------------------------------------------------------------------- 2 // <copyright file="UpdatePackageCmdlet.cs" company="Microsoft Corporation"> 3 // Copyright (c) Microsoft Corporation. Licensed under the MIT License. 4 // </copyright> 5 // ----------------------------------------------------------------------------- 6 7 namespace Microsoft.WinGet.Client.Commands 8 { 9 using System.Management.Automation; 10 using Microsoft.WinGet.Client.Commands.Common; 11 using Microsoft.WinGet.Client.Common; 12 using Microsoft.WinGet.Client.Engine.Commands; 13 using Microsoft.WinGet.Client.Engine.PSObjects; 14 15 /// <summary> 16 /// This commands updates a package from the pipeline or from the local system. 17 /// </summary> 18 [Cmdlet( 19 VerbsData.Update, 20 Constants.WinGetNouns.Package, 21 DefaultParameterSetName = Constants.FoundSet, 22 SupportsShouldProcess = true)] 23 [Alias("udwgp")] 24 [OutputType(typeof(PSInstallResult))] 25 public sealed class UpdatePackageCmdlet : InstallCmdlet 26 { 27 /// <summary> 28 /// Gets or sets a value indicating whether updating to an unknown version is allowed. 29 /// </summary> 30 [Parameter(ValueFromPipelineByPropertyName = true)] 31 public SwitchParameter IncludeUnknown { get; set; } 32 33 /// <summary> 34 /// Updates a package from the pipeline or from the local system. 35 /// </summary> 36 protected override void ProcessRecord() 37 { 38 var command = new InstallerPackageCommand( 39 this, 40 this.Override, 41 this.Custom, 42 this.Location, 43 this.AllowHashMismatch.ToBool(), 44 this.Force.ToBool(), 45 this.Header, 46 this.PSCatalogPackage, 47 this.Version, 48 this.Log, 49 this.Id, 50 this.Name, 51 this.Moniker, 52 this.Source, 53 this.Query, 54 this.SkipDependencies); 55 command.Update(this.IncludeUnknown.ToBool(), this.MatchOption.ToString(), this.Scope.ToString(), this.Architecture.ToString(), this.Mode.ToString(), this.InstallerType.ToString()); 56 } 57 } 58 }