microsoft / microsoft/winget-cli

Find-WinGetPackage always results in $? being true

Open
#4,861 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue-Bug PowerShell
Dominant language
C++
Stars
26.4k
Forks
1.8k
Avg merge
1d 11h
Merged PRs (30d)
15

Description

Brief description of your issue

When using Find-WinGetPackage, even when no packages are found, the result of $? will always be True

Steps to reproduce
Find-WinGetPackage -Id asdfasdfadsf; $?
Expected behavior

If one or more packages is found, $? should be true. If no packages are found $? should be false.
This should match the behavior of winget search where winget search Google.Chrome; $? returns true but winget search asdfasdfasdfad; $? returns false

Actual behavior

$? always returns true after Find-WinGetPackage

Environment
PS E:\winget-pkgs> winget --info
Windows Package Manager (Preview) v1.9.2411-preview
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.22631.4317
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.24.2411.0

PS E:\winget-pkgs> Get-Module -ListAvailable -Name Microsoft.WinGet.Client

    Directory: C:\Users\Trenly\Documents\PowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Binary     1.9.2411              Microsoft.WinGet.Client             Core,Desk {Get-WinGetVersion, Find-WinGetPackage, Get-WinGetPackage, Get-WinGetSource…}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Find-WinGetPackage entry point and reproduce the command shown in the issue, comparing its PowerShell success status with winget search. Trace how no-result searches are reported, then verify that the command returns true when a package is found and false when none is found.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, powershell
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.