Skip to content

Commit a7d85e8

Browse files
committed
For packages that depend on a specific version, search for them with NormalizedVersion
1 parent 1fca922 commit a7d85e8

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/code/FindHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ internal IEnumerable<PSResourceInfo> FindDependencyPackages(
11741174
else if(dep.VersionRange.MaxVersion != null && dep.VersionRange.MinVersion != null && dep.VersionRange.MaxVersion.OriginalVersion.Equals(dep.VersionRange.MinVersion.OriginalVersion))
11751175
{
11761176
string depPkgVersion = dep.VersionRange.MaxVersion.OriginalVersion;
1177-
FindResults responses = currentServer.FindVersion(dep.Name, version: dep.VersionRange.MaxVersion.OriginalVersion, _type, out ErrorRecord errRecord);
1177+
FindResults responses = currentServer.FindVersion(dep.Name, version: dep.VersionRange.MaxVersion.ToNormalizedString(), _type, out ErrorRecord errRecord);
11781178
if (errRecord != null)
11791179
{
11801180
if (errRecord.Exception is ResourceNotFoundException)

test/InstallPSResourceTests/InstallPSResourceV2Server.Tests.ps1

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,21 @@ Describe 'Test Install-PSResource for V2 Server scenarios' -tags 'CI' {
631631
$depRes.Name | Should -Be $depPkgName
632632
$depRes.Version | Should -Be $depPkgVer
633633
}
634+
635+
It "Install resource that takes a dependency on package with specific version with differing normalized and semver versions" {
636+
$moduleName = 'test-pkg-normalized-dependency'
637+
$version = '3.9.2'
638+
$depPkgName1 = "PowerShellGet"
639+
$depPkgName2 = "PackageManagement"
640+
641+
$res = Install-PSResource -Name $moduleName -Prerelease -Repository $PSGalleryName -TrustRepository -PassThru
642+
$res.Name | Should -Be $moduleName
643+
$res.Version | Should -Be $version
644+
645+
$depRes = Get-InstalledPSResource $depPkgName1, $depPkgName2
646+
$depRes.Name | Should -Contain $depPkgName1
647+
$depRes.Name | Should -Contain $depPkgName2
648+
}
634649
}
635650

636651
Describe 'Test Install-PSResource for V2 Server scenarios' -tags 'ManualValidationOnly' {

0 commit comments

Comments
 (0)