Add prerelease module as a requiredmodule in a psd1

Is there a way to have a prerelease module set as a required module in a psd1? I want my module to auto download the prerelease module when I install it from the gallery. In my case, Microsoft.PowerShell.SecretManagement.

My psd1 contains this under required modules:

RequiredModules = @(
@{ModuleName = ‘Microsoft.Powershell.SecretManagement’; ModuleVersion = ‘0.2.1’; Guid = ‘766a9266-f2ba-4146-bec2-bb30bf5a4f0a’}
)

Even with the Guid it still can’t be found using that syntax. I can’t specify 0.2.1-alpha1 as the version either.

Is there a possible workaround for this?

I Didn’t think too much, but feels like PSDepend would help you here.

https://github.com/RamblingCookieMonster/PSDepend