Repository navigation
Install-PSResource -RequiredResourceFile ignores the prerelease key if set to $true in a psd1 file #1794
Copy link
Copy link
Closed
Labels
Issue-BugSomething isn't workingSomething isn't working
Description
Activity
- addedIssue-BugSomething isn't workingSomething isn't workingand removed
on Apr 16, 2025 o-l-a-v commented
on Jul 7, 2025 ContributorMore actionsIf 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?
PSResourceGet/src/code/Utils.cs
Line 1285 in 06aec34
private static bool TryReadPSDataFile(
Or maybe it works as expected?
- added a commit that references this issue
on Aug 11, 2025
Metadata
Metadata
Assignees
Labels
Issue-BugSomething isn't workingSomething isn't working
Prerequisites
Steps to reproduce
test.psd1file as followsInstall-PSResource -RequiredResourceFile test.psd1Consider that the current prerelease version of
PrereleaseTestis0.0.2-prereleaseaccording to PSGallery.Expected behavior
Actual behavior
Error details
When importing from a json file, though, the prerelease setting is correctly respected.Environment data
Visuals