获取下载链接在IPackage of Nuget Core

时间:2016-06-01 11:38:53

标签: c# nuget

我找到了使用nuget api的示例代码。 我的任务是显示全名和下载链接。 这是代码:

        static void Main(string[] args)
        {
            //ID of the package to be looked up
            string packageID = "EntityFramework";

            //Connect to the official package repository
            IPackageRepository repo = PackageRepositoryFactory.Default.CreateRepository("https://packages.nuget.org/api/v2");

            //Get the list of all NuGet packages with ID 'EntityFramework'       
            List<IPackage> packages = repo.FindPackagesById(packageID).ToList();

            //Filter the list of packages that are not Release (Stable) versions
            packages = packages.Where(item => (item.IsReleaseVersion() == false)).ToList();

            //Iterate through the list and print the full name of the pre-release packages to console
            foreach (IPackage p in packages)
            {
                Console.WriteLine($"{p.GetFullName()};");
            }
        }

当我调试时,我看到要下载的链接,但我怎样才能获得此值? 我附上了调试信息的屏幕。 Debug info

Missing param

1 个答案:

答案 0 :(得分:0)

您可以执行此操作以获取下载链接:

foreach (var p in packages.ConvertAll(o => (DataServicePackage)o))
                {
    Console.WriteLine($"{p.GetFullName()};");
    Console.WriteLine(p.DownloadUrl.ToString())
}
相关问题