commit 2937bdfcb3681c45a53eabc6cc45fafc327fa956
parent 2b3923e40d770ae0b19ec83dc1571eec7d59a9d8
Author: Tanner Blomster <103529378+bftblomster@users.noreply.github.com>
Date: Mon, 25 Apr 2022 10:12:50 -0500
fix passing null parameters to Find-WinGetPackage (#2092)
Diffstat:
2 files changed, 33 insertions(+), 20 deletions(-)
diff --git a/tools/PowerShell/Microsoft.WinGet.Client/src/Library/Install-WinGetPackage.ps1 b/tools/PowerShell/Microsoft.WinGet.Client/src/Library/Install-WinGetPackage.ps1
@@ -102,65 +102,78 @@ Function Install-WinGetPackage
)
BEGIN
{
- [string[]] $WinGetArgs = "Install"
+ $WinGetFindArgs = @{}
+ [string[]] $WinGetInstallArgs = "Install"
IF($PSBoundParameters.ContainsKey('Filter')){
IF($Local) {
- $WinGetArgs += "--Manifest"
+ $WinGetInstallArgs += "--Manifest"
}
- $WinGetArgs += $Filter
+ $WinGetInstallArgs += $Filter
+ }
+ IF($PSBoundParameters.ContainsKey('Filter')){
+ IF($Local) {
+ $WinGetInstallArgs += "--Manifest"
+ }
+ $WinGetInstallArgs += $Filter
+ $WinGetFindArgs.Add('Filter', $Filter)
}
IF($PSBoundParameters.ContainsKey('Name')){
- $WinGetArgs += "--Name", $Name
+ $WinGetInstallArgs += "--Name", $Name
+ $WinGetFindArgs.Add('Name', $Name)
}
IF($PSBoundParameters.ContainsKey('Id')){
- $WinGetArgs += "--Id", $Id
+ $WinGetInstallArgs += "--Id", $Id
+ $WinGetFindArgs.Add('Id', $Id)
}
IF($PSBoundParameters.ContainsKey('Moniker')){
- $WinGetArgs += "--Moniker", $Moniker
+ $WinGetInstallArgs += "--Moniker", $Moniker
+ $WinGetFindArgs.Add('Moniker', $Moniker)
}
IF($PSBoundParameters.ContainsKey('Source')){
- $WinGetArgs += "--Source", $Source
+ $WinGetInstallArgs += "--Source", $Source
+ $WinGetFindArgs.Add('Source', $Source)
}
IF($PSBoundParameters.ContainsKey('Scope')){
- $WinGetArgs += "--Scope", $Scope
+ $WinGetInstallArgs += "--Scope", $Scope
}
IF($Interactive){
- $WinGetArgs += "--Interactive"
+ $WinGetInstallArgs += "--Interactive"
}
IF($Silent){
- $WinGetArgs += "--Silent"
+ $WinGetInstallArgs += "--Silent"
}
IF($PSBoundParameters.ContainsKey('Locale')){
- $WinGetArgs += "--locale", $Locale
+ $WinGetInstallArgs += "--locale", $Locale
}
if($PSBoundParameters.ContainsKey('Version')){
- $WinGetArgs += "--Version", $Version
+ $WinGetInstallArgs += "--Version", $Version
}
if($Exact){
- $WinGetArgs += "--Exact"
+ $WinGetInstallArgs += "--Exact"
+ $WinGetFindArgs.Add('Exact', $true)
}
if($PSBoundParameters.ContainsKey('Log')){
- $WinGetArgs += "--Log", $Log
+ $WinGetInstallArgs += "--Log", $Log
}
if($PSBoundParameters.ContainsKey('Override')){
- $WinGetArgs += "--override", $Override
+ $WinGetInstallArgs += "--override", $Override
}
if($PSBoundParameters.ContainsKey('Location')){
- $WinGetArgs += "--Location", $Location
+ $WinGetInstallArgs += "--Location", $Location
}
if($Force){
- $WinGetArgs += "--Force"
+ $WinGetInstallArgs += "--Force"
}
}
PROCESS
{
## Exact, ID and Source - Talk with Demitrius tomorrow to better understand this.
IF(!$Local) {
- $Result = Find-WinGetPackage -Filter $Filter -Name $Name -Id $Id -Moniker $Moniker -Tag $Tag -Command $Command -Source $Source
+ $Result = Find-WinGetPackage @WinGetFindArgs
}
if($Result.count -eq 1 -or $Local) {
- & "WinGet" $WingetArgs
+ & "WinGet" $WinGetInstallArgs
$Result = ""
}
elseif($Result.count -lt 1){
diff --git a/tools/PowerShell/Microsoft.WinGet.Client/src/Microsoft.WinGet.Client.psd1 b/tools/PowerShell/Microsoft.WinGet.Client/src/Microsoft.WinGet.Client.psd1
@@ -67,7 +67,7 @@ PowerShellVersion = '5.1'
# NestedModules = @()
# Functions to export from this module, for best performance, do not use wild cards and do not delete the entry, use an empty array if there are no functions to export.
-FunctionsToExport = @("Get-WinGetPackage", "Get-WinGetSource", "Get-WinGetVersion", "Add-WinGetSource")
+FunctionsToExport = '*'
# Cmdlets to export from this module, for best performance, do not use wild cards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()