update ValidateAndGet-RequiredModuleDetails to check preview version for dependency module

This commit is contained in:
Erich(Renyong) Wang 2020-03-06 16:59:31 +08:00
Родитель 74ccb3b1e0
Коммит a0c400dd17
2 изменённых файлов: 15 добавлений и 3 удалений

Просмотреть файл

@ -1937,7 +1937,7 @@ function Get-ModuleDependencies
if ($PSBoundParameters.ContainsKey('AllowPrerelease'))
{
$ValidateAndGetRequiredModuleDetails_Params.Add('AllowPrerelease',$Credential)
$ValidateAndGetRequiredModuleDetails_Params.Add('AllowPrerelease', $true)
}
$DependentModuleDetails += ValidateAndGet-RequiredModuleDetails @ValidateAndGetRequiredModuleDetails_Params
@ -8081,6 +8081,16 @@ function ValidateAndGet-RequiredModuleDetails
Microsoft.PowerShell.Core\Where-Object {$_.Name -eq $ModuleName} |
Microsoft.PowerShell.Utility\Select-Object -Last 1 -ErrorAction Ignore
if(-not $psgetItemInfo -and $PSBoundParameters.ContainsKey('AllowPrerelease') -and
$FindModuleArguments.ContainsKey('RequiredVersion') -and -not $FindModuleArguments['RequiredVersion'].Contains("-"))
{
$FindModuleArguments['RequiredVersion'] += "-preview";
$psgetItemInfo = Find-Module @FindModuleArguments |
Microsoft.PowerShell.Core\Where-Object {$_.Name -eq $ModuleName} |
Microsoft.PowerShell.Utility\Select-Object -Last 1 -ErrorAction Ignore
}
if(-not $psgetItemInfo)
{
$message = $LocalizedData.UnableToResolveModuleDependency -f ($ModuleName, $DependentModuleInfo.Name, $Repository, $ModuleName, $Repository, $ModuleName, $ModuleName)

Просмотреть файл

@ -483,9 +483,11 @@ function Save-PackageLocally {
# Only check for the modules that specifies = required exact dependency version
if ($RequiredVersion -ne $null) {
Write-Output "Checking for required module $ModuleName, $RequiredVersion"
if (Find-Module -Name $ModuleName -RequiredVersion $RequiredVersion -Repository $TempRepo -ErrorAction SilentlyContinue) {
if (Find-Module -Name $ModuleName -RequiredVersion $RequiredVersion -Repository $TempRepo -AllowPrerelease -ErrorAction SilentlyContinue) {
Write-Output "Required dependency $ModuleName, $RequiredVersion found in the repo $TempRepo"
} else {
} elseif (Find-Module -Name $ModuleName -RequiredVersion "$RequiredVersion-preview" -Repository $TempRepo -AllowPrerelease -ErrorAction SilentlyContinue) {
Write-Output "Required dependency $ModuleName, $RequiredVersion-preview found in the repo $TempRepo"
} else{
Write-Warning "Required dependency $ModuleName, $RequiredVersion not found in the repo $TempRepo"
Write-Output "Downloading the package from PsGallery to the path $TempRepoPath"
# We try to download the package from the PsGallery as we are likely intending to use the existing version of the module.