winget-cli icon indicating copy to clipboard operation
winget-cli copied to clipboard

pwsh Module Install-WinGetPackage terminating error

Open bftblomster opened this issue 3 years ago • 1 comments

So I started playing around with the Powershell module in https://github.com/microsoft/winget-cli/tree/master/tools/PowerShell/Microsoft.WinGet.Client/src

First thing is that it is limited to specific functions. I'm not sure if this is intentional or not but I changed this line in https://github.com/microsoft/winget-cli/blob/master/tools/PowerShell/Microsoft.WinGet.Client/src/Microsoft.WinGet.Client.psd1#L70 from: FunctionsToExport = @("Get-WinGetPackage", "Get-WinGetSource", "Get-WinGetVersion", "Add-WinGetSource") To: FunctionsToExport = '*'

This let me use the other functions.

Steps to reproduce

Run any Install-WinGetPackage command

Expected behavior

Continue to install package

Actual behavior

Terminating error Install-WinGetPackage -Id Zoom.Zoom -Exact You will get a bunch of null-value errors:

At C:\Program Files\WindowsPowerShell\Modules\Microsoft.WinGet.Client\0.1.0\Library\Find-WinGetPackage.ps1:91 char:13
+             $WinGetArgs += "--Name", $Name.Replace("…", "")
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\Microsoft.WinGet.Client\0.1.0\Library\Find-WinGetPackage.ps1:95 char:13
+             $WinGetArgs += "--Moniker", $Moniker.Replace("…", "")
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\Microsoft.WinGet.Client\0.1.0\Library\Find-WinGetPackage.ps1:99 char:13
+             $WinGetArgs += "--Tag", $Tag.Replace("…", "")
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\Microsoft.WinGet.Client\0.1.0\Library\Find-WinGetPackage.ps1:103 char:13
+             $WinGetArgs += "--Command", $Command.Replace("…", "")
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\Microsoft.WinGet.Client\0.1.0\Library\Find-WinGetPackage.ps1:111 char:13
+             $WinGetArgs += "--Source", $Source.Replace("…", "")
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Invoke-WinGetCommand : Cannot bind argument to parameter 'WinGetArgs' because it is an empty string.
At C:\Program Files\WindowsPowerShell\Modules\Microsoft.WinGet.Client\0.1.0\Library\Find-WinGetPackage.ps1:132 char:50
+         $List = Invoke-WinGetCommand -WinGetArgs $WinGetArgs -IndexTi ...
+                                                  ~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Invoke-WinGetCommand], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Invoke-WinGetCommand

Unable to locate package for installation

Environment

Windows Package Manager v1.2.10271
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.19044.1586
Package: Microsoft.DesktopAppInstaller v1.17.10271.0

Logs: %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir

Links
---------------------------------------------------------------------------
Privacy Statement   https://aka.ms/winget-privacy
License Agreement   https://aka.ms/winget-license
Third Party Notices https://aka.ms/winget-3rdPartyNotice
Homepage            https://aka.ms/winget
Windows Store Terms https://www.microsoft.com/en-us/storedocs/terms-of-sale

bftblomster avatar Apr 13 '22 21:04 bftblomster

Check PR #2092 for possible solution

bftblomster avatar Apr 13 '22 22:04 bftblomster

PowerShell Install

denelon avatar Apr 22 '23 20:04 denelon

This will be in the next preview release.

denelon avatar Apr 22 '23 20:04 denelon