有没有一种方式,文本或图形,查看nuget包之间的依赖的层次结构?
也可以在NuGet.Core中针对API编写代码。通过nuget安装:
原文链接:https://www.f2er.com/javaschema/282373.htmlinstall-package nuget.core
然后,您可以获取一个存储库对象并走过图表。这里是我刚刚构建的示例应用程序:
using System; using System.Collections.Generic; using System.Linq; using NuGet; namespace ConsoleApplication2 { class Program { static void Main() { var repo = new LocalPackageRepository(@"C:\Code\Common\Group\Business-Logic\packages"); IQueryable<IPackage> packages = repo.GetPackages(); OutputGraph(repo,packages,0); } static void OutputGraph(LocalPackageRepository repository,IEnumerable<IPackage> packages,int depth) { foreach (IPackage package in packages) { Console.WriteLine("{0}{1} v{2}",new string(' ',depth),package.Id,package.Version); IList<IPackage> dependentPackages = new List<IPackage>(); foreach (var dependency in package.Dependencies) { dependentPackages.Add(repository.FindPackage(dependency.Id,dependency.VersionSpec.ToString())); } OutputGraph(repository,dependentPackages,depth += 3); } } } }
在我的情况下,这个应用程序输出这样:
MyCompany.Castle v1.1.0.3 Castle.Windsor v2.5.3 Castle.Core v2.5.2 MyCompany.Common v1.1.0.6 CommonServiceLocator v1.0 MyCompany.Enum v1.1.0.7 MyCompany.Common v1.1.0.6 CommonServiceLocator v1.0 MyCompany.Enum v1.1.0.7 MyCompany.Enum v1.1.0.7 MyCompany.Versioning v1.3 Castle.Core v2.5.2 Castle.Windsor v2.5.3 Castle.Core v2.5.2 CommonServiceLocator v1.0 NUnit v2.5.10.11092 RhinoMocks v3.6