예제 #1
0
        /// <summary>
        /// Recursively adds the assemblies of a library and its dependencies
        /// </summary>
        /// <param name="libraryIdentifier">The identifier of the library</param>
        private void AddReferencesOfLibrary(LibraryIdentifier libraryIdentifier)
        {
            var library = LibraryAssemblyLocations.FirstOrDefault(lib => lib.Matches(libraryIdentifier));

            if (library == null)
            {
                Util.Log(
                    $@"Could not find the assembly path of a newly added library '{libraryIdentifier}' in projects.assets.json.
                    This is probably because the dependencies were not restored yet.");
                return;
            }


            var packageName    = libraryIdentifier.Name;
            var packageVersion = libraryIdentifier.Version.ToString();

            var packagePath = Path.Combine(NuGetPackageRoot, $"{packageName}/{packageVersion}/");

            // Add references of current library
            foreach (var assemblyPath in library.Assemblies)
            {
                References.AddIfNotContains(new PackageReference
                {
                    Name    = packageName,
                    Version = packageVersion,
                    Path    = Path.Combine(packagePath, assemblyPath)
                });
            }

            // Recursively add the references of the dependencies
            foreach (var dependency in library.Dependencies)
            {
                AddReferencesOfLibrary(dependency);
            }
        }