in src/DependencyManagement/PowerShellGalleryModuleProvider.cs [31:74]
public string GetLatestPublishedModuleVersion(string moduleName, string majorVersion)
{
// The PowerShellGallery uri to query for the latest module version.
const string PowerShellGalleryFindPackagesByIdUri =
"https://www.powershellgallery.com/api/v2/FindPackagesById()?id=";
Uri address = new Uri($"{PowerShellGalleryFindPackagesByIdUri}'{moduleName}'");
var expectedVersionStart = majorVersion + ".";
Version latestVersion = null;
do
{
var stream = _searchInvoker.Invoke(address);
if (stream == null)
{
break;
}
// Load up the XML response
XmlDocument doc = new XmlDocument();
using (XmlReader reader = XmlReader.Create(stream))
{
doc.Load(reader);
}
// Add the namespaces for the gallery xml content
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("a", "http://www.w3.org/2005/Atom");
nsmgr.AddNamespace("d", "http://schemas.microsoft.com/ado/2007/08/dataservices");
nsmgr.AddNamespace("m", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");
XmlNode root = doc.DocumentElement;
latestVersion = GetLatestVersion(root, nsmgr, expectedVersionStart, latestVersion);
// The response may be paginated. In this case, the current page
// contains a link to the next page.
address = GetNextLink(root, nsmgr);
}
while (address != null);
return latestVersion?.ToString();
}