Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/code/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1196,24 +1196,24 @@ internal static void GetMetadataFilesFromPath(string dirPath, string packageName
if (string.Compare($"{packageName}.psd1", fileName, StringComparison.OrdinalIgnoreCase) == 0)
{
properCasingPkgName = Path.GetFileNameWithoutExtension(file);
psd1FilePath = file;
}
psd1FilePath = file;
}
else if (file.EndsWith("nuspec"))
{
if (string.Compare($"{packageName}.nuspec", fileName, StringComparison.OrdinalIgnoreCase) == 0)
{
properCasingPkgName = Path.GetFileNameWithoutExtension(file);
nuspecFilePath = file;
}
nuspecFilePath = file;
}
else if (file.EndsWith("ps1"))
{
if (string.Compare($"{packageName}.ps1", fileName, StringComparison.OrdinalIgnoreCase) == 0)
{
properCasingPkgName = Path.GetFileNameWithoutExtension(file);
ps1FilePath = file;
}
ps1FilePath = file;
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions test/FindPSResourceTests/FindPSResourceLocal.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -338,4 +338,15 @@ Describe 'Test Find-PSResource for local repositories' -tags 'CI' {
$res.Version | Should -Be $nupkgVersion
$res.Prerelease | Should -Be $prereleaseLabel
}

It "find module that has multiple manifests and use exact name match one" {
# Az.KeyVault has 2 manifest files - Az.KeyVault.psd1 and Az.KeyVault.Extension.psd1
# this test was added because PSResourceGet would previously pick the .psd1 file by pattern matching the module name, not exact matching it
# this meant Az.KeyVault.Extension.psd1 and its metadata was being returned.
# The package is present on PSGallery but issue reproduces when looking at the package's file paths in local repo
$PSGalleryName = Get-PSGalleryName
Save-PSResource -Name 'Az.KeyVault' -Version '6.3.1' -Repository $PSGalleryName -AsNupkg -Path $localRepoUriAddress -TrustRepository
$res = Find-PSResource -Name 'Az.KeyVault' -Repository $localRepo
$res.Version | Should -Be "6.3.1"
}
}
Loading