public LibraryManager(FrameworkName targetFramework, string configuration, DependencyWalker dependencyWalker, ILibraryExportProvider libraryExportProvider) : this(targetFramework, configuration, GetLibraryInfoThunk(dependencyWalker), libraryExportProvider) { }
public void MissingDependenciesAreIgnored() { var testProvider = new TestDependencyProvider() .Package("a", "1.0", that => that.Needs("x", "1.0")); var walker = new DependencyWalker(new[] { testProvider }); walker.Walk("a", new SemanticVersion("1.0"), VersionUtility.ParseFrameworkName("net45")); AssertDependencies(testProvider.Dependencies, that => that .Needs("a", "1.0")); }
public void NearestDependencyVersionWins() { var testProvider = new TestDependencyProvider() .Package("a", "1.0", that => that.Needs("b", "1.0").Needs("c", "1.0").Needs("x", "1.0")) .Package("b", "1.0", that => that.Needs("x", "2.0")) .Package("c", "1.0", that => that.Needs("x", "2.0")) .Package("x", "1.0") .Package("x", "2.0"); var walker = new DependencyWalker(new[] { testProvider }); walker.Walk("a", new SemanticVersion("1.0"), VersionUtility.ParseFrameworkName("net45")); AssertDependencies(testProvider.Dependencies, that => that .Needs("a", "1.0") .Needs("b", "1.0") .Needs("c", "1.0") .Needs("x", "1.0")); }
public ModuleLoaderContext(IServiceProvider serviceProvider, string projectDirectory) { ProjectDirectory = projectDirectory; RootDirectory = Microsoft.Framework.Runtime.ProjectResolver.ResolveRootDirectory(ProjectDirectory); // A new project resolver is required. you cannot reuse the one from the // parent service provider as that will be for the parent context. ProjectResolver = new ProjectResolver(ProjectDirectory, RootDirectory); var referenceAssemblyDependencyResolver = new ReferenceAssemblyDependencyResolver(new FrameworkReferenceResolver()); // Need to pass through package directory incase you download a package from the gallary, this needs to know about it var nuGetDependencyProvider = new NuGetDependencyResolver(new PackageRepository( NuGetDependencyResolver.ResolveRepositoryPath(RootDirectory))); var gacDependencyResolver = new GacDependencyResolver(); var projectDepencyProvider = new ProjectReferenceDependencyProvider(ProjectResolver); var unresolvedDependencyProvider = new UnresolvedDependencyProvider(); var projectLockJsonPath = Path.Combine(ProjectDirectory, LockFileFormat.LockFileName); if (File.Exists(projectLockJsonPath)) { var lockFileFormat = new LockFileFormat(); var lockFile = lockFileFormat.Read(projectLockJsonPath); nuGetDependencyProvider.ApplyLockFile(lockFile); } DependencyWalker = new DependencyWalker(new IDependencyProvider[] { projectDepencyProvider, nuGetDependencyProvider, referenceAssemblyDependencyResolver, gacDependencyResolver, unresolvedDependencyProvider }); LibraryExportProvider = new CompositeLibraryExportProvider(new ILibraryExportProvider[] { new ModuleProjectLibraryExportProvider( ProjectResolver, serviceProvider), referenceAssemblyDependencyResolver, gacDependencyResolver, nuGetDependencyProvider }); }
private static Func<IEnumerable<ILibraryInformation>> GetLibraryInfoThunk(DependencyWalker dependencyWalker) { return () => dependencyWalker.Libraries .Select(library => new LibraryInformation(library)); }
public void RejectedDependenciesToNotCarryConstraints() { // a1->b1-*d1->e2->x2 // a1->c1->d2 // a1->c1->e1->x1 // * b1->d1 lower than c1->d2 so d1->e2->x2 are n/a var testProvider = new TestDependencyProvider() .Package("a", "1.0", that => that.Needs("b", "1.0").Needs("c", "1.0")) .Package("b", "1.0", that => that.Needs("d", "1.0")) .Package("c", "1.0", that => that.Needs("d", "2.0").Needs("e", "1.0")) .Package("d", "1.0", that => that.Needs("e", "2.0")) .Package("d", "2.0") .Package("e", "1.0", that => that.Needs("x", "1.0")) .Package("e", "2.0", that => that.Needs("x", "2.0")) .Package("x", "1.0") .Package("x", "2.0") .Package("g", version: null); var walker = new DependencyWalker(new[] { testProvider }); walker.Walk("a", new SemanticVersion("1.0"), VersionUtility.ParseFrameworkName("net45")); // the d1->e2->x2 line has no effect because d2 has no dependencies, AssertDependencies(testProvider.Dependencies, that => that .Needs("a", "1.0") .Needs("b", "1.0") .Needs("c", "1.0") .Needs("d", "2.0") .Needs("e", "1.0") .Needs("x", "1.0")); }
public void RecursiveDependenciesAreNotFollowed() { var testProvider = new TestDependencyProvider() .Package("a", "1.0", that => that.Needs("b", "1.0")) .Package("b", "1.0", that => that.Needs("c", "1.0")) .Package("c", "1.0", that => that.Needs("d", "1.0").Needs("b", "1.0")) .Package("d", "1.0", that => that.Needs("b", "1.0")); var walker = new DependencyWalker(new[] { testProvider }); walker.Walk("a", new SemanticVersion("1.0"), VersionUtility.ParseFrameworkName("net45")); AssertDependencies(testProvider.Dependencies, that => that .Needs("a", "1.0") .Needs("b", "1.0") .Needs("c", "1.0") .Needs("d", "1.0")); }