InstallCmdlet.cs (2701B)
1 // ----------------------------------------------------------------------------- 2 // <copyright file="InstallCmdlet.cs" company="Microsoft Corporation"> 3 // Copyright (c) Microsoft Corporation. Licensed under the MIT License. 4 // </copyright> 5 // ----------------------------------------------------------------------------- 6 7 namespace Microsoft.WinGet.Client.Commands.Common 8 { 9 using System.IO; 10 using System.Management.Automation; 11 using Microsoft.WinGet.Client.PSObjects; 12 13 /// <summary> 14 /// This is the base class for all commands that parse a FindPackagesOptions result 15 /// from the provided parameters i.e., the "install" and "upgrade" commands. 16 /// </summary> 17 public abstract class InstallCmdlet : InstallerSelectionCmdlet 18 { 19 private string location; 20 21 /// <summary> 22 /// Gets or sets the mode to manipulate the package with. 23 /// </summary> 24 [Parameter(ValueFromPipelineByPropertyName = true)] 25 public PSPackageInstallMode Mode { get; set; } = PSPackageInstallMode.Default; 26 27 /// <summary> 28 /// Gets or sets the override arguments to be passed on to the installer. 29 /// </summary> 30 [Parameter(ValueFromPipelineByPropertyName = true)] 31 public string Override { get; set; } 32 33 /// <summary> 34 /// Gets or sets the arguments to be passed on to the installer in addition to the defaults. 35 /// </summary> 36 [Parameter(ValueFromPipelineByPropertyName = true)] 37 public string Custom { get; set; } 38 39 /// <summary> 40 /// Gets or sets the installation location. 41 /// </summary> 42 [Parameter(ValueFromPipelineByPropertyName = true)] 43 public string Location 44 { 45 get => this.location; 46 set 47 { 48 this.location = Path.IsPathRooted(value) 49 ? value 50 : this.SessionState.Path.CurrentFileSystemLocation + @"\" + value; 51 } 52 } 53 54 /// <summary> 55 /// Gets or sets the path to the logging file. 56 /// </summary> 57 [Parameter(ValueFromPipelineByPropertyName = true)] 58 public string Log { get; set; } 59 60 /// <summary> 61 /// Gets or sets a value indicating whether to continue upon non security related failures. 62 /// </summary> 63 [Parameter(ValueFromPipelineByPropertyName = true)] 64 public SwitchParameter Force { get; set; } 65 66 /// <summary> 67 /// Gets or sets the optional HTTP Header to pass on to the REST Source. 68 /// </summary> 69 [Parameter(ValueFromPipelineByPropertyName = true)] 70 public string Header { get; set; } 71 } 72 }