Skip to content

Install-PSResource -RequiredResourceFile ignores the prerelease key if set to $true in a psd1 file #1794

Description

@matteocoder

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues.

Steps to reproduce

  1. Create a test.psd1 file as follows
@{
	'PrereleaseTest' = @{
        'repository' = 'PSGallery'
        prerelease = $True
        'Scope'      = 'CurrentUser'
    }
}
  1. run Install-PSResource -RequiredResourceFile test.psd1

Consider that the current prerelease version of PrereleaseTest is 0.0.2-prerelease according to PSGallery.

Expected behavior

import-module prereleasetest; get-module prereleasetest
ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Manifest   0.0.2      prerelease           prereleasetest

Actual behavior

import-module prereleasetest; get-module prereleasetest
ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Manifest   0.0.1                 prereleasetest

Error details

When importing from a json file, though, the prerelease setting is correctly respected.

Environment data

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Binary     1.1.0                 Microsoft.PowerShell.PSResourceGet  {Compress-PSResource, Find-PSResource, Get-Instal…


Name                           Value
----                           -----
PSVersion                      7.6.0-preview.2
PSEdition                      Core
GitCommitId                    7.6.0-preview.2
OS                             Microsoft Windows 10.0.26100
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

Image

Activity

  1. o-l-a-v commented on Jul 7, 2025

    @o-l-a-v
    Contributor

    If you treat it like a string inside test.psd1, like so:

    @{
    	'PrereleaseTest' = @{
            'repository' = 'PSGallery'
            'prerelease' = 'True'
            'Scope'      = 'CurrentUser'
        }
    }

    This is also shown as an example here: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.psresourceget/install-psresource?view=powershellget-3.x#example-5

    Then it works:

    PS > $DebugPreference = 'Continue'; Install-PSResource -TrustRepository -RequiredResourceFile "C:\Users\olavb\Desktop\Temp\test.psd1" -WhatIf
    
    DEBUG: In GetHelper::GetPackagesFromPath()
    DEBUG: In GetHelper::FilterPkgPathsByName()
    DEBUG: In GetHelper::FilterPkgPathsByVersion()
    DEBUG: Searching through package path: 'C:\Users\olavb\Documents\PowerShell\Modules\Microsoft.PowerToys.Configure'
    DEBUG: Searching through package path: 'C:\Users\olavb\Documents\PowerShell\Modules\Microsoft.PowerToys.Configure'
    DEBUG: Searching through package version path: 'C:\Users\olavb\Documents\PowerShell\Modules\Microsoft.PowerToys.Configure\0.92.0.0'
    DEBUG: In InstallPSResource::RequiredResourceHelper()
    DEBUG: In InstallPSResource::ProcessInstallHelper()
    DEBUG: In InstallHelper::BeginInstallPackages()
    DEBUG: Parameters passed in >>> Name: 'PrereleaseTest'; VersionRange: ''; NuGetVersion: ''; VersionType: 'NoVersion'; Version: ''; Prerelease: 'True'; Repository: 'PSGallery'; AcceptLicense: 'False'; Quiet: 'False'; Reinstall: 'False'; TrustRepository: 'True'; NoClobber: 'False'; AsNupkg: 'False'; IncludeXml 'True'; SavePackage 'False'; TemporaryPath ''; SkipDependencyCheck: 'False'; AuthenticodeCheck: 'False'; PathsToInstallPkg: 'C:\Users\olavb\Documents\PowerShell\Modules,C:\Users\olavb\Documents\PowerShell\Scripts'; Scope 'CurrentUser'
    DEBUG: In InstallHelper::ProcessRepositories()
    DEBUG: In InstallHelper::InstallPackages()
    DEBUG: In InstallHelper::InstallPackage()
    DEBUG: In V2ServerAPICalls::FindName()
    DEBUG: In V2ServerAPICalls::HttpRequestCall()
    DEBUG: Request url is 'https://www.powershellgallery.com/api/v2/FindPackagesById()?%24filter=Id+eq+%27PrereleaseTest%27+and+IsAbsoluteLatestVersion+eq+true&%24inlinecount=allpages&id=%27PrereleaseTest%27'
    What if: Performing the operation "Install-PSResource" on target "Package to install: 'PrereleaseTest', version: '0.0.2-prerelease'".
    
    PS >

    But using bool, also in a hashtable directly like so:

    $DebugPreference = 'Continue'; Install-PSResource -TrustRepository -RequiredResource @{
        'PrereleaseTest' = @{
            'repository' = 'PSGallery'
            'prerelease' = $true
            'Scope'      = 'CurrentUser'
        }
    } -WhatIf

    fails.


    Maybe something should be done with the parsing? Would that be here?

    Or maybe it works as expected?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions