PowerShell / PSResourceGet

PSResourceGet is the package manager for PowerShell
https://www.powershellgallery.com/packages/Microsoft.PowerShell.PSResourceGet
MIT License
485 stars 92 forks source link

Update-PSResource fails with prerelease resources #1196

Closed ThomasNieto closed 1 year ago

ThomasNieto commented 1 year ago

Prerequisites

Steps to reproduce

If you try to update all resources with a prerelease only resource then it will fail to find those Related issue: https://github.com/PowerShell/PSResourceGet/issues/890.

Expected behavior

# works

Actual behavior

Update-PSResource -PassThru
Update-PSResource: Package with search criteria: Name Microsoft.PowerShell.PSResourceGet could not be found due to: Package does not exist on the server..
Update-PSResource: Package with search criteria: Name Microsoft.PowerShell.TextUtility could not be found due to: Package does not exist on the server..
Update-PSResource: Object reference not set to an instance of an object.

Error details

Exception             :
    Type       : System.NullReferenceException
    TargetSite :
        Name          : MoveNext
        DeclaringType : Microsoft.PowerShell.PSResourceGet.Cmdlets.FindHelper+<FindDependencyPackages>d__21,
Microsoft.PowerShell.PSResourceGet, Version=0.5.22.0, Culture=neutral, PublicKeyToken=null
        MemberType    : Method
        Module        : Microsoft.PowerShell.PSResourceGet.dll
    Message    : Object reference not set to an instance of an object.
    Source     : Microsoft.PowerShell.PSResourceGet
    HResult    : -2147467261
    StackTrace :
   at Microsoft.PowerShell.PSResourceGet.Cmdlets.FindHelper.FindDependencyPackages(ServerApiCall currentServer,
ResponseUtil currentResponseUtil, PSResourceInfo currentPkg, PSRepositoryInfo repository, HashSet`1
foundPkgs)+MoveNext()
   at Microsoft.PowerShell.PSResourceGet.Cmdlets.FindHelper.SearchByNames(ServerApiCall currentServer, ResponseUtil
currentResponseUtil, PSRepositoryInfo repository)+MoveNext()
   at Microsoft.PowerShell.PSResourceGet.Cmdlets.FindHelper.FindByResourceName(String[] name, ResourceType type,
VersionRange versionRange, NuGetVersion nugetVersion, VersionType versionType, String version, Boolean prerelease,
String[] tag, String[] repository, Boolean includeDependencies)+MoveNext()
   at Microsoft.PowerShell.PSResourceGet.Cmdlets.UpdatePSResource.ProcessPackageNames(String[] namesToProcess,
VersionRange versionRange, NuGetVersion nuGetVersion, VersionType versionType)
   at Microsoft.PowerShell.PSResourceGet.Cmdlets.UpdatePSResource.ProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()
CategoryInfo          : NotSpecified: (:) [Update-PSResource], NullReferenceException
FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.PSResourceGet.Cmdlets.UpdatePSResource
InvocationInfo        :
    MyCommand        : Update-PSResource
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 14
    Line             : Update-PSResource -PassThru
    Statement        : Update-PSResource -PassThru
    PositionMessage  : At line:1 char:1
                       + Update-PSResource -PassThru
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Update-PSResource
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

Environment data

7.4-preview3
beta22

Visuals

No response

anamnavi commented 1 year ago

@ThomasNieto thanks for reporting this! I am able to partially reproduce this...It gives me an error saying that my prerelease resource does not exist on the server (for which we'll correct that error messaging). I can't repro the null pointer exception you reported though. Do you mind sharing the output of Get-InstalledPSResource so we can see which module that is, I'm wondering if it runs into an error while getting it, finding it or updating it.

alerickson commented 1 year ago

@ThomasNieto can you share what you passed in to the cmdlet?

I just tried updating PowerShellGet 3.0.20-beta20 and was able to successfully install 3.0.21-beta21, I did pass in the -Prerelease parameter though.

ThomasNieto commented 1 year ago

@alerickson there were no parameters besides -PassThru

ThomasNieto commented 1 year ago

@anamnavi here are my installed modules.

Name                                  Version
----                                  -------
AnyPackage                            0.5.1
AnyPackage.Chocolatey                 0.1.3
AnyPackage.Msu                        0.2.3
AnyPackage.PowerShellGet              0.2.4
AnyPackage.Programs                   0.2.1
AnyPackage.Scoop                      0.1.4
AnyPackage.WinGet                     0.0.7
AnyPackageDsc                         0.1.1
AnyPackageDsc                         0.1.0
Cobalt                                0.4.0
CompletionPredictor                   0.1.0
ConvertToSARIF                        1.0.0.0
Foil                                  0.3.0
kbupdate                              2.0.26
kbupdate-library                      1.1.22
Microsoft.PowerShell.ConsoleGuiTools  0.7.2.0
Microsoft.PowerShell.PSResourceGet    0.5.22
Microsoft.PowerShell.SecretManagement 1.1.2
Microsoft.PowerShell.SecretStore      1.0.6.0
Microsoft.PowerShell.TextUtility      0.1.0
Microsoft.WinGet.Client               0.2.1
PackageManagement                     1.4.8.1
Pester                                5.4.1
platyPS                               0.14.2
posh-git                              1.1.0
PowerGit                              0.9.0
PowerShellGet                         2.2.5.1
PSDesiredStateConfiguration           2.0.6.0
PSFramework                           1.7.270
PSReadLine                            2.3.1
PSReadLine                            2.3.0
PSScriptAnalyzer                      1.21.0
PSSQLite                              1.1.0
Scoop                                 0.1.2
TabExpansionPlusPlus                  1.2
TreeSize                              2.0