diff --git a/src/Microsoft.Framework.PackageManager/Restore/NuGet/HttpSource.cs b/src/Microsoft.Framework.PackageManager/Restore/NuGet/HttpSource.cs index 16b15701c..08a12ee28 100644 --- a/src/Microsoft.Framework.PackageManager/Restore/NuGet/HttpSource.cs +++ b/src/Microsoft.Framework.PackageManager/Restore/NuGet/HttpSource.cs @@ -155,7 +155,7 @@ await ConcurrencyUtilities.ExecuteWithFileLocked(result.CacheFileName, async _ = } } - // If the desitnation file doesn't exist, we can safely perform moving operation. + // If the destination file doesn't exist, we can safely perform moving operation. // Otherwise, moving operation will fail. if (!File.Exists(result.CacheFileName)) { diff --git a/src/Microsoft.Framework.PackageManager/Restore/NuGet/NuGetv2Feed.cs b/src/Microsoft.Framework.PackageManager/Restore/NuGet/NuGetv2Feed.cs index 722657268..94870bb99 100644 --- a/src/Microsoft.Framework.PackageManager/Restore/NuGet/NuGetv2Feed.cs +++ b/src/Microsoft.Framework.PackageManager/Restore/NuGet/NuGetv2Feed.cs @@ -21,6 +21,10 @@ public class NuGetv2Feed : IPackageFeed private static readonly XName _xnameProperties = XName.Get("properties", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"); private static readonly XName _xnameId = XName.Get("Id", "http://schemas.microsoft.com/ado/2007/08/dataservices"); private static readonly XName _xnameVersion = XName.Get("Version", "http://schemas.microsoft.com/ado/2007/08/dataservices"); + private static readonly XName _xnamePublish = XName.Get("Published", "http://schemas.microsoft.com/ado/2007/08/dataservices"); + + // An unlisted package's publish time must be 1900-01-01T00:00:00. + private static readonly DateTime _unlistedPublishedTime = new DateTime(1900, 1, 1, 0, 0, 0); private readonly string _baseUri; private readonly Reports _reports; @@ -89,7 +93,7 @@ public async Task> FindPackagesByIdAsyncCore(string id) var page = 1; while (true) { - // TODO: Pages for a package Id are cahced separately. + // TODO: Pages for a package Id are cached separately. // So we will get inaccurate data when a page shrinks. // However, (1) In most cases the pages grow rather than shrink; // (2) cache for pages is valid for only 30 min. @@ -104,7 +108,8 @@ public async Task> FindPackagesByIdAsyncCore(string id) var result = doc.Root .Elements(_xnameEntry) - .Select(x => BuildModel(id, x)); + .Select(x => BuildModel(id, x)) + .Where(x => x != null); results.AddRange(result); @@ -170,6 +175,16 @@ public PackageInfo BuildModel(string id, XElement element) var idElement = properties.Element(_xnameId); var titleElement = element.Element(_xnameTitle); + var publishElement = properties.Element(_xnamePublish); + if (publishElement != null) + { + DateTime publishDate; + if (DateTime.TryParse(publishElement.Value, out publishDate) && (publishDate == _unlistedPublishedTime)) + { + return null; + } + } + return new PackageInfo { // If 'Id' element exist, use its value as accurate package Id diff --git a/src/Microsoft.Framework.PackageManager/Restore/RestoreCommand.cs b/src/Microsoft.Framework.PackageManager/Restore/RestoreCommand.cs index 7f4f88fa6..274e9d224 100644 --- a/src/Microsoft.Framework.PackageManager/Restore/RestoreCommand.cs +++ b/src/Microsoft.Framework.PackageManager/Restore/RestoreCommand.cs @@ -41,7 +41,7 @@ public RestoreCommand(IApplicationEnvironment env) public string PackageFolder { get; set; } public string GlobalJsonFile { get; set; } - public string RestorePackageId { get; set; } + public string RestorePackageId { get; set; } public string RestorePackageVersion { get; set; } public string AppInstallPath { get; private set; }