in Source/NuGetGallery.Operations/Tasks/CurateWebmatrixPackagesTask.cs [24:93]
public override void ExecuteCommand()
{
Log.Trace("Getting latest packages...");
var packages = GetLatestStablePackages();
Log.Trace("Getting previously curated packages...");
var alreadyCuratedPackageIds = GetAlreadyCuratedPackageIds();
Log.Trace("Calculating minimum difference set...");
var packageIdsToCurate = packages.Keys.Except(alreadyCuratedPackageIds).ToList();
var totalCount = packageIdsToCurate.Count;
var processedCount = 0;
Log.Trace(
"Curating {0} packages for the WebMatrix curated on '{1}',",
totalCount,
ConnectionString);
Parallel.ForEach(packageIdsToCurate, new ParallelOptions { MaxDegreeOfParallelism = 10 }, packageIdToCurate =>
{
var package = packages[packageIdToCurate];
try
{
var downloadPath = DownloadPackage(package);
var nugetPackage = new ZipPackage(downloadPath);
var shouldBeIncluded = nugetPackage.Tags != null && nugetPackage.Tags.ToLowerInvariant().Contains("aspnetwebpages");
if (!shouldBeIncluded)
{
shouldBeIncluded = true;
foreach (var file in nugetPackage.GetFiles())
{
var fi = new FileInfo(file.Path);
if (fi.Extension == ".ps1" || fi.Extension == ".t4")
{
shouldBeIncluded = false;
break;
}
}
}
if (shouldBeIncluded)
{
AddPackageToCuratedFeed(package);
}
File.Delete(downloadPath);
Interlocked.Increment(ref processedCount);
Log.Info(
"{2} package '{0}.{1}' ({3} of {4}).",
package.Id,
package.Version,
shouldBeIncluded ? "Curated" : "Ignored",
processedCount,
totalCount);
}
catch(Exception ex)
{
Interlocked.Increment(ref processedCount);
Log.Error(
"Error curating package '{0}.{1}' ({2} of {3}): {4}.",
package.Id,
package.Version,
processedCount,
totalCount,
ex.Message);
}
});
}