@@ -286,7 +286,8 @@ public override Stream InstallPackage(string packageName, string packageVersion,
286
286
return results ;
287
287
}
288
288
289
- results = InstallVersion ( packageName , packageVersion , out errRecord ) ;
289
+ string packageNameForInstall = PrependMARPrefix ( packageName ) ;
290
+ results = InstallVersion ( packageNameForInstall , packageVersion , out errRecord ) ;
290
291
return results ;
291
292
}
292
293
@@ -1601,13 +1602,14 @@ private Hashtable[] FindPackagesWithVersionHelper(string packageName, VersionTyp
1601
1602
string registryUrl = Repository . Uri . ToString ( ) ;
1602
1603
string packageNameLowercase = packageName . ToLower ( ) ;
1603
1604
1605
+ string packageNameForFind = PrependMARPrefix ( packageNameLowercase ) ;
1604
1606
string containerRegistryAccessToken = GetContainerRegistryAccessToken ( out errRecord ) ;
1605
1607
if ( errRecord != null )
1606
1608
{
1607
1609
return emptyHashResponses ;
1608
1610
}
1609
1611
1610
- var foundTags = FindContainerRegistryImageTags ( packageNameLowercase , "*" , containerRegistryAccessToken , out errRecord ) ;
1612
+ var foundTags = FindContainerRegistryImageTags ( packageNameForFind , "*" , containerRegistryAccessToken , out errRecord ) ;
1611
1613
if ( errRecord != null || foundTags == null )
1612
1614
{
1613
1615
return emptyHashResponses ;
@@ -1616,7 +1618,7 @@ private Hashtable[] FindPackagesWithVersionHelper(string packageName, VersionTyp
1616
1618
List < Hashtable > latestVersionResponse = new List < Hashtable > ( ) ;
1617
1619
List < JToken > allVersionsList = foundTags [ "tags" ] . ToList ( ) ;
1618
1620
1619
- SortedDictionary < NuGet . Versioning . SemanticVersion , string > sortedQualifyingPkgs = GetPackagesWithRequiredVersion ( allVersionsList , versionType , versionRange , requiredVersion , packageNameLowercase , includePrerelease , out errRecord ) ;
1621
+ SortedDictionary < NuGet . Versioning . SemanticVersion , string > sortedQualifyingPkgs = GetPackagesWithRequiredVersion ( allVersionsList , versionType , versionRange , requiredVersion , packageNameForFind , includePrerelease , out errRecord ) ;
1620
1622
if ( errRecord != null )
1621
1623
{
1622
1624
return emptyHashResponses ;
@@ -1627,7 +1629,7 @@ private Hashtable[] FindPackagesWithVersionHelper(string packageName, VersionTyp
1627
1629
foreach ( var pkgVersionTag in pkgsInDescendingOrder )
1628
1630
{
1629
1631
string exactTagVersion = pkgVersionTag . Value . ToString ( ) ;
1630
- Hashtable metadata = GetContainerRegistryMetadata ( packageNameLowercase , exactTagVersion , containerRegistryAccessToken , out errRecord ) ;
1632
+ Hashtable metadata = GetContainerRegistryMetadata ( packageNameForFind , exactTagVersion , containerRegistryAccessToken , out errRecord ) ;
1631
1633
if ( errRecord != null || metadata . Count == 0 )
1632
1634
{
1633
1635
return emptyHashResponses ;
@@ -1694,6 +1696,18 @@ private Hashtable[] FindPackagesWithVersionHelper(string packageName, VersionTyp
1694
1696
return sortedPkgs ;
1695
1697
}
1696
1698
1699
+ private string PrependMARPrefix ( string packageName )
1700
+ {
1701
+ string prefix = string . IsNullOrEmpty ( InternalHooks . MARPrefix ) ? PSRepositoryInfo . MARPrefix : InternalHooks . MARPrefix ;
1702
+
1703
+ // If the repostitory is MAR and its not a wildcard search, we need to prefix the package name with MAR prefix.
1704
+ string updatedPackageName = Repository . IsMARRepository ( ) && packageName . Trim ( ) != "*"
1705
+ ? string . Concat ( prefix , packageName )
1706
+ : packageName ;
1707
+
1708
+ return updatedPackageName ;
1709
+ }
1710
+
1697
1711
#endregion
1698
1712
}
1699
1713
}
0 commit comments